richpl / PyBasic

Simple interactive BASIC interpreter written in Python
GNU General Public License v3.0
165 stars 45 forks source link

Tab() behavior #46

Closed RetiredWizard closed 2 years ago

RetiredWizard commented 2 years ago

Changes the behavior of the Tab function to place the cursor at the specified column rather than returning a string of the specified number of spaces.

After this update if the Tab function is used in an assignment to a string variable an error will be displayed. Oddly enough, if an integer variable is assigned the tab function the variable will receive a python Tuple which can't really be used by BASIC, however if the integer variable is printed it will be treated as though the original tab was printed.

RetiredWizard commented 2 years ago

Well after updating the README for this PR, I got to thinking and came up with an alternate way of getting this done that left the TAB function as a normal string function that returns a string of blanks unless it's used as an print statement item in which case it sets the column of the next output. I'll go ahead and create another branch and pull request for that option as well. I think that's a better option because it doesn't have the TAB function return a python tuple but both options do the same thing when the tab is used on a print statement which was actually all I was originally looking for.