Question

So, I'm struggling with a school project, I have a BASIC code, that is programmed on a PALM, I need to translate that to LabView, so first I'm translating the code to pseudocode, but I've never used BASIC before, so I'm having trouble with some lines.

So far, I know that: VariableName# = 15, means the type of the variable is double, and that it can be used on the right side of a number to convert it to double, like VariableName# = 15#

I also have on my code: OPEN "LPT1" FOR OUTPUT AS #1, opens serial port found on COM1, and names it "LPT1"

But a few lines later I found this, and I don't know what is it supposed to do:

225 FOR J = 1 TO 6000: PRINT #1, 40; : NEXT J
226 FOR ZZ = 1 TO S9: PRINT #1, 41; : NEXT ZZ

I know how FOR statements work, but what is it supposed to print?

PS: It's a solar positioning system.

edit: S9 is defined at the beggining of the program, it's 450.

Was it helpful?

Solution 2

Lines 225 and 226 are printing to #1 which is mapped to line printer 1 (e.g. the parallel port and usually a centronics connectors)

OPEN "LPT1" FOR OUTPUT AS #1

Next, decimal 40 and 41 are ( and ) respectively. So it's formatting and printing those symbols to your printer.

OTHER TIPS

I think what happens is it outputs 40 on that port 6000 times (see link for file output in BASIC) and then 41. Not sure what S9 is.

LPT1 is usually a parallel port, COM1 is a serial port, so there might something fishy going on.

From the same link:

PRINT #

The PRINT # command writes data to a file - the data is written to the file whose number follows "#". The command works like the PRINT command, except that the information is sent to the file instead of printed to the screen. The statement

All print #1 means is that it is going to output any information you do from that point on to #1, which in your case is "LPT1", Anything after this print will go to it until there is the phrase "Close #1"

As for S9, I believe that would be a variable that is set somewhere in the program. Try using CTRL-F in the code to find S9 somewhere else in the program. If you are using GW-Basic as the interpretter, type in 'save "NAME.txt",a' to get a text file. The only other thing I could assume it would translate to is for ZZ= 1 to (infinity) step 9, which is unrealistic but would make it count by 9 until it couldn't count any more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top