General Category > Programming

BASIC programming tips

<< < (28/28)


--- Quote from: Gryzor on 12:31, 15 February 20 ---But this will increase your listing length 😄

--- End quote ---

Only to show a rundown of the process involved, it's that short a routine that it can be entered as a series of statements like this:

--- Code: ---a=&170:v=PEEK(&170):n=0:FOR L=1 TO 10:PRINT v:n = a + v:a = n:v = PEEK(n):CALL &BB18:NEXT L
--- End code ---

or from a KEY <num>,... statement.

The code works by obtaining the actual length of each line, BASIC programmes begin at &170 or 368 with the 1st byte representing that Line Length, so to get the Line Length of the second line and so on, the address (a) is added with the Line Length value (v) to get the new value (n) and then address (a) becomes that new value (n) and v becomes the next Line Length and so on until L = 10.

So I tested it on the Red's Exit game I wrote back in 2017 for the BASIC 10-Liners Contest and to my surprise 1 of the 10 Lines exceeded the Length category the game was put in, the funny thing about that is when a character count is carried out, it comes up shorter, which kind of explains why in some cases if too many variables are used on the same line a "Line Too Long" Error results.

Though here are the results I got from Red's Exit:

--- Code: ---102

--- End code ---

The normal use of TAG / MOVE is that if you PRINT"HELLO EVERYBODY" too close from the right side of the screen, the text will be cut, where I would prerfer it to go on writing on the left. I guess the system is detecting if the text is exceeding the right limit of "640 pixels", where I would prefer it to going on writing wherever it is.

Do you know if there is a magical POKE to let the text write ?

[ot]Out of this subject :
As I am not really fluent english speaker, I don't read all the topics, so I juste discovered the old Morri question, 3 years after.

--- Quote from: Morri ---Does anyone have some simple BASIC code to have the following sequence of numbers...
1 2 3 2 1 2 3 2 1 2 3 etc...
I can do it in the following code but just wondering if someone can do it faster
--- End quote ---
I am surprised not to have read a such simple solution :

--- Code: ---10 FOR x=-1 to 2:PRINT 1+ABS(x);:NEXT
--- End code ---

Limits of graphics area are sets by command ORIGIN. If setting this way doesn't work, you can try by POKE.

Kernel guide shows adress of pixel x margin:

for 6128 at &B69B and &B69D (2byte both)
for  464 at &B330 and &B332

Let me know is it help. :)

New version of  "Hello World"  in one line of pure Basic. :)

10 MODE 0:BORDER 0:FOR i=0 TO 15:INK i,ASC(MID$("@YXOFCDHQTKBAIRV",i+1,1))-64:NEXT:WHILE-1:FOR p=1 TO 15 STEP 0.5:PEN p:s=(s+1)MOD 18:LOCATE VAL(MID$("112345678998765432",s+1,1)),1:PRINT"Hello World!"CHR$(30)CHR$(11):NEXT:WEND


[0] Message Index

[*] Previous page

Go to full version
Powered by SMFPacks Reactions Mod
Powered by SMFPacks Alerts Pro Mod
Powered by SMFPacks Mentions Pro Mod