Monday, May 31, 2010

Translator – PRINT Command (Translation)

The translated statement PRINT will consist of a number of different printing codes, which include PrintDbl, PrintInt, PrintStr, PrintTmpStr, Comma, Semicolon, and Print. The print only Spc and Tab internal function codes will also print. Before explaining further, here are some examples with their translations:
PRINT  Print
PRINT A;B%  A PrintDbl B PrintInt Print
PRINT A$+B$,C$;  A$ B$ + PrintTmpStr Comma C$ PrintStr
PRINT TAB(A+1);"Hello"  A 1 + Tab "Hello" PrintStr Print
PRINT "Start";SPC(10)  "Start" PrintStr 10 Spc
PRINT ,,A  Comma Comma A PrintDbl Print
PRINT ;  Semicolon
Note that when the cursor is to go to a new line, there is a Print code at the end of the translation, otherwise it is absent. The Print code at run-time preforms the new line action, so in it's absence, the cursor remains on the same line. The PrintDbl, PrintInt, PrintStr and PrintTmpStr will output the value that is on top of the evaluation stack, with PrintTmpStr deleting the temporary string when done.

At run-time, the Comma code will advance the cursor to the next column by outputting spaces. The Tab and Spc codes perform there action by outputting spaces. The Semicolon code does not perform any action during run-time, it is there only so that it can't reproduced during recreation of the source. Next, how the PRINT statement will be translated...

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)