youki Posted May 1, 2020 Share Posted May 1, 2020 Hello, i have a newbie question. I'm toying with Inty Basic. is there a way to split a BASIC line in multiple lines? For instance , i would like to write something like : if #backtab(#pos_joueur) = ECHELLE1 or #backtab(#pos_joueur) = ECHELLE2 or #backtab(#pos_joueur) = ECHELLE3 or #backtab(#pos_joueur) = ECHELLE4 or #backtab(#pos_joueur) = ECHELLE5 or #backtab(#pos_joueur) = ECHELLE6 then .... end if instead of if #backtab(#pos_joueur) = ECHELLE1 or #backtab(#pos_joueur) = ECHELLE2 or #backtab(#pos_joueur) = ECHELLE3 or #backtab(#pos_joueur) = ECHELLE4 or #backtab(#pos_joueur) = ECHELLE5 or #backtab(#pos_joueur) = ECHELLE6 then ... end if I have tested to put all "new line" character i knew from other BASIC (like & , _ , / ) it seems IntyBASIC does not support them. thanks for your help. 1 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted May 1, 2020 Share Posted May 1, 2020 (edited) You can use the inverted slash character at the end of the line. Like this: if #backtab(#pos_joueur) = ECHELLE1 \ or #backtab(#pos_joueur) = ECHELLE2 \ or #backtab(#pos_joueur) = ECHELLE3 \ or #backtab(#pos_joueur) = ECHELLE4 \ or #backtab(#pos_joueur) = ECHELLE5 \ or #backtab(#pos_joueur) = ECHELLE6 then .... end if BTW, it is more efficient to use the idiom (a=1)+(b=2)+(c=3) as the OR operation isn't implemented into Intellivision processor and uses several instructions to be processed. Edited May 1, 2020 by nanochess 2 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted May 2, 2020 Share Posted May 2, 2020 You might also want to load #backtab(#pos_joueur) into a temporary variable, as it appears IntyBASIC (at least v1.4.1) doesn't re-use the value it loaded. #tmp = #backtab(#pos_joueur) IF (#tmp = ECHELLE1) \ + (#tmp = ECHELLE2) \ + (#tmp = ECHELLE3) \ + (#tmp = ECHELLE4) \ + (#tmp = ECHELLE5) \ + (#tmp = ECHELLE6) THEN ' ... stuff ... END IF Assuming ECHELLE1 through ECHELLE6 are constants, there may be even better ways to write this depending on what the values are. I did try writing up a generic "FIND" assembly helper. Counting the cycles, it's about the same as using a temp variable in the worst case (value not found), and shows bigger wins when the value is found in the list: ' Call this as USR Find(VARPTR table(0), length, value) ' Returns 1 through N if found, or 0 if not. ASM FIND: PROC ASM MOVR R0, R4 ASM @@1: CMP@ R4, R2 ASM BEQ @@2 ASM DECR R1 ASM BNEQ @@1 ASM MOVR R0, R4 ASM @@2: SUBR R0, R4 ASM MOVR R4, R0 ASM JR R5 ASM ENDP ' Usage example: IF USR Find(VARPTR items(0), 6, #backtab(#pos_joueur)) > 0 THEN ' ... stuff ... END IF ' Elsewhere, outside a Procedure: items: DATA ECHELLE1, ECHELLE2, ECHELLE3 DATA ECHELLE4, ECHELLE5, ECHELLE6 With that kind of helper, you could also start to use ON Find(...) GOTO or ON Find(...) GOSUB to do even fancier things. 4 Quote Link to comment Share on other sites More sharing options...
youki Posted May 2, 2020 Author Share Posted May 2, 2020 Thanks a lot Nanochess and Intvnut for your hints! I don't know why i didn't not try the inverted slash character before... as i had tried all i could think about... but seems not that one... 2 Quote Link to comment Share on other sites More sharing options...
youki Posted May 2, 2020 Author Share Posted May 2, 2020 hum... strange it does not work for me... look at the attached picture. (it is late here, may be i have missed something very obvious...) I was sure i had tried all characters i could think about...:) 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted May 2, 2020 Share Posted May 2, 2020 The backslash needs to be the absolute last character on the line. This red dot hints you have a space character causing trouble. 1 Quote Link to comment Share on other sites More sharing options...
youki Posted May 2, 2020 Author Share Posted May 2, 2020 thanks a lot , it works now! 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.