Help with data type conversion
thetribster
Posts: 11
I am new to this forum and to SPIN, interesting language.
Anyway, I have a string:
tel.str(string("/WB3Day.php?z=33051:"))
and an a Long named pagenumber. I'd like to append the pagenumber to the tel.str - just after the 33051: so it would look like this:
/WB3Day.php?z=33051:1 (assuming pagenumber = 1).
I'm having difficulty with the language, hopefully the experienced devs here can help. Thanks in advance.
Anyway, I have a string:
tel.str(string("/WB3Day.php?z=33051:"))
and an a Long named pagenumber. I'd like to append the pagenumber to the tel.str - just after the 33051: so it would look like this:
/WB3Day.php?z=33051:1 (assuming pagenumber = 1).
I'm having difficulty with the language, hopefully the experienced devs here can help. Thanks in advance.
Comments
tel.str(string("/WB3Day.php?z=33051:"))
tel.dec(pagenumber)
tel.str(@path_holder)
tel.dec(pagenumber)
tel.str(string(":"))
if settings.getData(settings#NET_MAC_ADDR,@infostack,6) ' Grab the MAC address, display it
tel.str(string("MAC: "))
repeat i from 0 to 5
if i
tel.str(string("-"))
tel.hex(byte[noparse][[/noparse]@infostack],2)
The path_holder value is: "/IW.php?Dave:" I then append the pagenumber on. I would now like to add the mac address - the IF construct is meant to handle it but all I get is '-' and not the address. Help [noparse]:)[/noparse]
How is infostack defined?
The infostack is defined as a long[noparse][[/noparse]200].
The pathholder variable is Byte[noparse][[/noparse]128].
Thx for the quick responses!
Here is code that takes the MAC addrress out of memory and writes it to the screen (this works):
[noparse][[/noparse] code ]
if settings.getData(settings#NET_MAC_ADDR,@infostack,6) ' Grab the MAC address, display it
term.str(string("MAC: "))
repeat i from 0 to 5
if i
term.out("-")
term.hex(byte[noparse][[/noparse]@infostack],2)
term.out(13)
[noparse][[/noparse] /code ]
Here is what I am currently doing that is not working:
[noparse][[/noparse] code ]
case pagenumber
0 :
tel.str(@path_holder)
tel.dec(pagenumber)
tel.str(string(":"))
if settings.getData(settings#NET_MAC_ADDR,@infostack,6) ' Grab the MAC address
tel.str(string("MAC: "))
repeat i from 0 to 5
if i
tel.str(string("-"))
tel.hex(byte[noparse][[/noparse]@infostack],2)
tel.str(string("/BC.php?p="))
[noparse][[/noparse] /code ]
Also, preview is your friend.
BTW, the path_holder value just before the pagenumber concatenation is:
/IW_0.php?p=33051:
then the pagenumber is added /IW_0.php?p=33051:1 - this works (thanks to Mike). Now, I'd like to add another colon (easy enough) and the MAC string - so the result looks something like this:
/IW_0.php?p=33051:1:FFDDFF0966FF
the second widget of code (in the earlier post) is where I am having the problem.
This is the original InfoWidget for the yBox that I've transformed into a generic RSS reader (and a little more) - just an FYI in case you know anything about the yBox.
Anyway...What I need to be able to do is append ":" + pagenumber + ":" + macaddr to the existing path_holder string (or create a new one). I am a funbling idiot with SPIN.
Thanks Mike, your help and responsiveness are appreciated - very much - I'm way better at writing PHP/PERL code [noparse]:)[/noparse]
First, I got a compile error on the function name 'length' so I changed to lgth.
Secondly, while the infostack is being passed in the main routine it isn't populated with the right data - i.e. the mac addr. I added a line to hydrate with the mac addr before calling your build rouint.
The code is below. Now that I can do this dynamically (tell the prop the next page to call) from the server side I can eliminate the case construct...
The is very cool for me, a major item is now done and I can focus on the server side 100%.
Mike, I can't thank you enough for your help through this - wish I could do something for you.
Also, I noticed your StringIO routines are being downloaded by others
Here is the current !working! code.