Page 3 of 21
Suitable for Basic extensions ?
Posted: Wed Apr 14, 2010 7:14 am
by wimoos
Can BasEdit.NET be customized so that it understands Basic extensions, such as WaterLoo Structured Basic or Exbasic ?
Posted: Wed Apr 14, 2010 7:50 am
by Schlowski
Should be fairly easy, I maintain a token table for standard BASIC V2 and SuperExpander right now.
Code: Select all
aToken(128) = "end"
aToken(129) = "for"
aToken(130) = "next"
aToken(131) = "data"
aToken(132) = "input#"
...
I think some basic extensions use 2 byte tokens, right? This would require some modifications in my code, but nothing too serious. Additionally I should take the opportunity to make these token tables user definable with some external files, so BasEdit is freely configurable for any basic extension.
Can you provide me with a token list for ExBasic / WimBasic / WaterLoo Structured Basic?
Posted: Wed Apr 14, 2010 8:25 am
by Boray
Posted: Wed Apr 14, 2010 8:52 am
by Schlowski
Great - I knew I had seen such tables before...
And just to make this post a little bit more interesting: New version uploaded, another bugfix: Renumber only replaced the first jump after ON x GOTO/GOSUB, now fixed.
Posted: Wed Apr 14, 2010 10:38 am
by Mike
Schlowski wrote:I think some basic extensions use 2 byte tokens, right?
Waterloo BASIC even uses 3 byte tokens.
Code: Select all
IF := $F3 $FF $FF
CALL := $F4 $FF $FF
LOOP := $F5 $FF $FF
ENDLOOP := $F6 $FF $FF
UNTIL := $F7 $FF $FF
WHILE := $F8 $FF $FF
ELSEIF := $F9 $FF $FF
ELSE := $FA $FF $FF
ENDIF := $FB $FF $FF
PROC := $FC $FF $FF
ENDPROC := $FD $FF $FF
QUIT := $FE $FF $FF
The second, and third byte are replaced as the program runs, with a pointer to the destination line of the loop/select/call construct. So, when they're executed the second time, they don't anymore need to search for the destination, and that speeds up things.
For this mechanism to work correctly, all the new keywords (with the exception of CALL, and QUIT) need to be first in a line. The manual even states, that *all* commands should be written in separate lines - but that strict requirement can be restricted to the new commands indeed. The new IF variant is not anymore followed by THEN with a multi-line-if.
Waterloo BASIC still accepts the old IF token for backwards compatibility to programs written with CBM BASIC V2, but that one does not, and cannot commence a IF .. ELSEIF .. ELSE .. ENDIF. They're listed the same, and upon an edit, the old IF is converted into a new IF.
Finally, the manual also discourages the use of GOTO, and GOSUB, as they can confuse the new commands as well. But they shouldn't be anymore necessary then, anyway.
P.S.: For those who use the version of Waterloo BASIC included with Mega-Cart - SYS44444 does an OLD after reset.

tokens for WimBasic / Exbasic
Posted: Wed Apr 14, 2010 1:20 pm
by wimoos
Here it comes for WimBasic. For Exbasic XOR ==> DEC and UNNEW ==> HARDCOPY
Regards,
Wim.
; OFF $01
; RENUM $02
; FIND $03
; DEL $04
; AUTO $05
; DUMP $06
; VPLOT $07
; CALL $08
; BORDER $09
; EXEC $0a
; MERGE $0b
; HPLOT $0c
; DOKE $0d
; SPACE $0e
; INPUTLINE $0f
; SET $10
; KEY $11
; CURSOR $12
; COLOR $13
; SOUND $14
; PLAY $15
; VOLUME $16
; RESET $dc
; MEM $dd
; TRACE $de
; BASIC $df
; RESUME $E0
; LETTER $e1
; HELP $e2
; COKE $e3
; GROUND $e4
; MATRIX $e5
; DISPOSE $e6
; PRINT@ $e7
; HIMEM $e8
; UNNEW $e9
; INPUTFORM $ea
; LOCK $eb
; SWAP $ec
; USING $ed
; SEC $ee
ELSE $ef
ERROR $f0
; ROUND $f1
; DEEK $f2
; STRING$ $f3
; POINT $f4
; INSTR $f5
; CEEK $f6
; MIN $f7
; MAX $f8
; VARPTR $f9
; FRAC $fa
; ODD $fb
; XOR $fc
; HEX$ $fd
; EVAL $fe
Posted: Thu Apr 15, 2010 11:34 am
by Schlowski
Ok, finally managed to implement different token sets. Loadable via BasEdit.Ini for the moment.
Had much fun with the multi-byte tokens and the Waterloo Basic speciality with the extra bytes and overlapping keywords END / ENDLOOP / ENDPROC / LOOP. I made some tests with Basic V7, Waterloo Basic and WimBasic and everything seems to be fine. But since this was a more heavy change in code than I initially thought there may be some issues left. So any test and feedback is welcome!
Following Basic tokenlists implemented:
Code: Select all
TokenList_AtBasic.txt
TokenList_BasicV10.txt
TokenList_BasicV2.txt
TokenList_BasicV3.5.txt
TokenList_BasicV4.txt
TokenList_BasicV4_C64.txt
TokenList_BasicV7.txt
TokenList_ExbasicLevel2.txt
TokenList_SpeechBasicV2.7.txt
TokenList_SuperExpander.txt
TokenList_TurtleBasic.txt
TokenList_WaterlooBasic.txt
TokenList_WimBasic.txt
Thanks to Boray for the link and Wimoos for the tokens for Exbasic/WimBasic.
Just insert the desired file in BasEdit.Ini:
Tokenfiles have the following structure:
Code: Select all
; blablabla - comment
#include <anytextfile> - include another file
end,$80 - keyword END, token $80 (=128)
endloop,$F6,2 - keyword ENDLOOP, token $F6 (=246), two additional bytes in PRG file, ignored on load, filled with $FF on write
Should be straightforward, just take a look at the samples.
Posted: Thu Apr 15, 2010 2:26 pm
by wimoos
Great work ! This is really becoming a terrific programming tool !
Wimoos.
Posted: Thu Apr 15, 2010 2:33 pm
by Boray
Schlowski wrote:
Thanks to Boray for the link
And thank you for BasEdit! I found that link when researching to make the Plus/4 vs Vic-20 analysing in PRG Starter.
Posted: Thu Apr 15, 2010 3:13 pm
by Schlowski
Tokenizer updated - with all these basic extensions my simple tokenizer routine got hit by the complexity to distinguish LOAD from DLOAD, detect VERIFY and not verIFy but understand that A=AANDB means a=aANDb, i.e sometimes keywords are in the middle of words, sometimes not, etc.
I hope now my solution generates compatible files for all Basic extensions.
Posted: Thu Apr 15, 2010 4:24 pm
by Schlowski
Another update - Mike showed me an error concerning shifted chars, which looked ok but did not work in a program:
Code: Select all
1GETA$:IFA$="{shift-s}"THENPRINT"OK!"
2GOTO1
This did not work, one could press {shift-s} for an eternity, "OK!" would never be printed.
I had to add 96 to characters in the range from 97 to 127 resulting in 193 to 223, then everything runs fine.
Funny thing is that CHR$(97) results in the same character as CHR$(97+96).
POKE <> ASCII <> PETSCII <> TOKENCODE, thank god that Commodore did not care about UNICODE

Posted: Fri Apr 16, 2010 5:56 am
by Schlowski
Update:
- fixed a bug when doing a backspace after the physical end of a line (thx Wimoos for pointing me to this error)
- added replace, replaces all occurances of a string by another
- fixed wrong character code generation in search dialog (follow up to Mikes error)
Posted: Tue Apr 20, 2010 3:34 am
by Schlowski
Working on label mode, i.e. replacing all line numbers with labels and eliminating all unneded labels.
While creating these labels the source is split to single instructions per line where applicable and automatically indented a little bit for better reading.
In label mode detection of line numbers is replaced by detection of labels for syntax highlighting, this was a bit tricky but seems to be ok right now.
For the moment I'm concentrating on Basic V2, I will have to enhance the keyword files with some additional information like indentation, if a keyword follows a line number and if a line break is allowed after certain keywords. But before fiddling with enhanced Basics I want to be able to go back, i.e. generate from program in label mode a valid Basic V2 program.
Sample of what I have achieved so far:
Original source to Videopoker - this is the complete source, even in Basic V2 mode this is much easier to read and follow than on the VIC with 22x23 characters...
And this is what you get after a click on "Convert line# to labels" - this does not fit in one screen as breaking up the long lines results in 313 instead of 83 lines:

Posted: Tue Apr 20, 2010 2:21 pm
by Boray
This sounds interesting indeed!

THEN in Exbasic/Wimbasic
Posted: Wed Apr 21, 2010 2:46 am
by wimoos
Please note that in Exbasic and in Wimbasic, THEN can be omitted when this does not lead to ambiguity.