Page 1 of 1

First Program

Posted: Tue Jan 08, 2013 3:45 am
by TuLithu
Last night, I wrote my first QBASIC program, which went something like this:

CLS
FOR I% = 0 to 255
PRINT CHR$(I%);
NEXT I%
END

For some reason, the program began by printing ASCII character 014. I couldn't figure out what was going on, so I tried changing it to this:

CLS
FOR I% = 1 to 256
PRINT CHR$(I% - 1);
NEXT I%
END

This gave me an error message which led me to believe that the index variable in QBASIC is actually an array. So, what is going on in these programs? Please, don't give me the answer to this program, but if someone can give me a hint why these don't work, that would be great. Forgive my ignorance...I have only programmed before in UCBLogo :-)

Posted: Tue Jan 08, 2013 10:13 pm
by burger2227
ASCII character 7 beeps, 9 backspaces, 10 linefeeds, 11 vertical tabs, 12 formfeeds, and 13 is Return. After that you are home free except for characters 28 through 31 that don't print and 32 is a space.

CHR$(256) does not exist.

Thank you...

Posted: Wed Jan 09, 2013 4:00 am
by TuLithu
So the reason I didn't see anything before 14 was because of ASCII code 13, which executed a carriage return. As you can see, I've never written a program using ASCII codes :oops:

Posted: Wed Jan 09, 2013 12:08 pm
by burger2227
You can print them all in QB64 with _CONTROLCHR OFF before the PRINTs.

You can use Unicode too.