IonicWind Software

Aurora Compiler => General Discussion => Topic started by: kryton9 on July 19, 2006, 06:46:46 PM

Title: why am I getting the ascii character set when doing this?
Post by: kryton9 on July 19, 2006, 06:46:46 PM
I am getting the ascii character set when this program runs while I was expecting it to print from 0 to 255.

global sub main()
{
   def b as unsigned byte;
   for(b=0; b<256;b++)
   {
      print(b," ",);
      while getkey() ="";// gives you time to see what is happening. I just hold it down till I am done.
   }
   while getkey() ="";// the program doesn't get here, so I just close the window
}
Title: Re: why am I getting the ascii character set when doing this?
Post by: Ionic Wind Support Team on July 19, 2006, 07:15:33 PM
The Print function translates it to a displayable character.  Convert it to an int, or just add zero ;)

print(b+0,"",);

Adding zero elevates it to an integer.  You can also use NumToStr

print(NumToStr(b), "" ,);

Title: Re: why am I getting the ascii character set when doing this?
Post by: kryton9 on July 19, 2006, 07:29:51 PM
Thanks Paul :)
Title: Re: why am I getting the ascii character set when doing this?
Post by: Protected on July 19, 2006, 07:33:53 PM
Why can't you cast the character to an integer, C-style?
Title: Re: why am I getting the ascii character set when doing this?
Post by: Ionic Wind Support Team on July 19, 2006, 08:12:49 PM
Because this isn't C. 
Title: Re: why am I getting the ascii character set when doing this?
Post by: Parker on July 21, 2006, 12:34:43 AM
No, but some type of casting is really needed. Either a new unary operator, like %(int)byte_var, or something like the word "cast" would work - cast(int)byte_var (this is what the D language uses).