Is there a limit as to how many times you can use the LOCATE command on a line in BASIC?
I'm trying to use the PEN and LOCATE commands in a remake of a BASIC adventure from the BBC but the the first line. in which I use two LOCATE commands in the same line, the second one doesn't work.
LOCATE 14,1 works but LOCATE 29,1 won't, taking the text for it to the next line. I've tried to spread it over different lines but sadly no go.
Am I doing something wrong or is it a limitation?
Thanks
Why use LOCATE at all, when you can just add a semicolon to the print statements so they don't automatically append a newline?
Third print is too long.
Try first and second print ending ; and not use locate
A friend suggested the semi-colons - i took out the LOCATE commands and put ; instead of : but ended up with a Syntax Error.
I can't upload a picture but this is what the line looked like:
1010 PRINT"You are in a ";PEN 2:PRINT"lovely garden. ";PEN 1:PRINT"A note on the door says: "
or with all :'s replaced with ;
1010 PRINT"You are in a ";PEN 2;PRINT"lovely garden. ";PEN 1;PRINT"A note on the door says: "
I've even tried putting each part of the text to be printed on separate lines but no go. It's the same with or without the : in the final printed line.
Semikolon after the print command. But then you still need the colon to separate commands.
Print "a";:pen 2:print "b"
Works great thanks!
FWIW, LOCATE can be used multiple times in a line just fine. The problem is Locomotive BASIC is very finicky about where a PRINT starts. If it decides there isn't enough room on the current line, it'll always start a new one even if the previous PRINT ended with a ;
I have a vague feeling you can avoid it by doing ZONE 255 as long as you aren't relying on , in your PRINT statements.
Indeed... I remember that this annoyed me a lot in the 80s. Is there any way to force BASIC to continue printing?
Attached is the comment in the manual.
Like I say, I think issuing ZONE 255 first, which makes the "print zone" as big as it can be, mostly makes the issue go away - although I don't think it was a perfect solution, but the details are foggy. Embedding control codes in a string so you don't need multiple PRINT statements can help too, but obviously then the limit of 255 characters per string becomes more of a problem.
I just found out how it can be done. You can add control codes to your output instead of locate - and then it always starts printing at the position.
(I use a$ but it can also be a static text like in the first post here)
10 locate 5,10:print a$
can also be expressed as
10 print chr$(31)+chr$(5)+chr$(10)+a$
However it behaves differently, if a$ is longer than the rest of the line. In the first case it will be moved into the next line. In the second case it will still start at 5,10 and print as expected.
Also you must use + and not ; as with a ; it will again start in the next line.
Quote from: andycadley on 09:46, 14 February 25Like I say, I think issuing ZONE 255 first, which makes the "print zone" as big as it can be, mostly makes the issue go away - although I don't think it was a perfect solution, but the details are foggy. Embedding control codes in a string so you don't need multiple PRINT statements can help too, but obviously then the limit of 255 characters per string becomes more of a problem.
I just tried and I don't see a change in behaviour with "ZONE 255"
Thanks all
CTRL+A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
give ASCI 1,2,3,4,5,6,7,8,9,.......................................,26
ZONE affects what spacing will be after using a comma. It doesn't work on LOCATE, or place after ;
@eto - In your example, plus sign is only necessary before a$, and pluses between CHR$ are unnecessary.
There is another way to make long texts start by LOCATE close to right margin:
LOCATE 35,10:PRINT USING"&";"long text"
Clearly a false memory on my part. I know it wasn't long before I ended up writing various text routines of my own, so it may be one of the reasons why. I did think there was some sort of simple workaround though, but maybe I've just forgotten.
Thanks all - the next thing to do is put all the room descriptions into arrays as to make it more authentic to the BBC original, I'm going to use double height text..
Due to some unrelated issues with BASIC, the BASIC version of the game is on hold and the whole thing is being done in GAC instead..