forums

TNT Basic Forums > Bugs!
String Bug
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-14-2006 23:04

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

This is a very strange bug, I have no idea why it's true.

Code:

Global int r[3], e
...
a()
print e '--- This comes out to be 'yes'
str s=upper case(e)
if s="YES" or s="Y" then print "same"

...
procedure a()
r[0]="yes"
e=r[0]
...


The word 'same' does not print.

02-15-2006 16:08

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

A Bug?

The only problem here seems to be that 'Upper Case()' isn't converting integers to upper case strings.

You have to remember that you are not passing the address of the string, but the string itself, so your code will only work with strings that are 3 characters or less (an int is four characters, so you can have three significant and one terminator). The array idea wouldn't make a difference (although technically if you pass the array identifier without parenthesis, it 'could' work, as the name is the address of the array and the index is the amount to add to that address to get the value you want... That's why indexing starts at zero by the way.), basically you were loading 'r(0)' with the string, but r(0) is just another integer, and would be treated as such (I assume). You are not loading each element of the array with a single character.

I hope this clears that one up... It's not a bug, it's just the supplied calls reacting appropriately to a pretty strange bit of code.

Danny (nods)

02-15-2006 16:26

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

Sorry

Those are strings, I posted the code wrong.

02-15-2006 19:05

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

OK...

Changed them to strings and it worked fine...

Danny (nods)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.