General area when it fits no where else

Moderator: Mmiscool

User avatar
By viscomjim
#37586 I am trying to write a small parser for my little www clock that will show the ip address of the clock once it joins the network. For the life of me, I cannot understand why this little slice of code is not working. The right string function seems to want to add a "." at the end of the result.

Here is a simplified piece of the code giving me fits, and then the result.

Code: Select allipstr$ = 192.168.1.12
serialprint "ipstr$ = "
serialprintln ipstr$
serialprintln ""
serialprint "length of ipstr$ = "
serialprintln len(ipstr$)
serialprintln ""
check = 8
temp$ = right(ipstr$,check)
serialprint "temp$ = "
serialprintln temp$
serialprintln ""
serialprint "length of temp$ = "
serialprintln len(temp$)
serialprintln ""
end


The result when run...

Code: Select allipstr$ = 192.168.1.12

length of ipstr$ = 12

temp$ = 168.1.12.

length of temp$ = 9

Done...


You can see that when I get the temp$, it has an extra dot at the end for some reason. I ask for the 8 rightmost characters in the ipstr$ and I get the extra dot and the length shows up as 9. What in tarnations am I not getting here? Can someone try this simple code and see if they get the same result?

I am using espbasic version 1.69

Thanks a million.

Edit...

I did a variable dump and the temp$ shows correctly without the dot at the end. Not sure why it shows up after the right string function but not in the variable dump. Of course this hoses the parser...
User avatar
By TassyJim
#37592 I added a bit more to test a few things.
Code: Select allipstr$ = 192.168.1.12
serialprint "ipstr$ = "
serialprintln ipstr$
serialprintln ""
serialprint "length of ipstr$ = "
serialprintln len(ipstr$)
serialprintln ""
check = 8
temp$ = right(ipstr$,check)
serialprint "temp$ = "
serialprintln temp$
serialprintln ""
serialprint "length of temp$ = "
serialprintln len(temp$)
serialprintln ""
temp$ = temp$ & "*"
serialprint "temp$ = "
serialprintln temp$
serialprintln ""
serialprint "length of temp$ = "
serialprintln len(temp$)
serialprintln ""
test$ = mid(temp$,9,1)
ch = asc(test$)
serialprintln ch
end

The "*" is not shown although according to the length it has been added.
The last test shows a zero value at the 9th position of the temp$
I think chr(0) is getting added to the string with the RIGHT() function.

You can get around the problem with left(temp$,len(temp$)-1)

Jim
User avatar
By Mmiscool
#37596 Just uploaded a new build. Should be working as expected now.