BasEdit.NET

You need an actual VIC.

Moderator: Moderators

User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

IF <cond> THEN line#
IF <cond> GOTO line#
IF <cond> GOSUB line#

would be recognized for tokenizing, detokenizing and converting line numbers to labels.

Anything else which I should be aware of?
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

In V2 can also be used:

ON <var> GOTO / GOSUB line# [,line#, ...]
LIST and RUN also take linenumbers, but that won't be used much

In Exbasic/Wimbasic the following constructs are also possible and valid:

IF <cond> ELSE line#
ON ERROR GOTO line#
[ON <var>] RESTORE line#[,line#,...]
RESUME line#


Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

ON <var> GOTO/GOSUB line#[, line#,...] is already implemented
LIST [line#][-line#] - missing
RUN [line#] - should be easy, it's like a standard GOTO line#

For Exbasic/Wimbasic:
IF <cond> ELSE line# - ELSE must be handled like THEN, to be implemented
ON ERROR GOTO line# - already implemented since this construct will be treated like GOTO line#
[ON <var>] RESTORE line#[,line#,...] - should be easy, treat RESTORE like GOTO and everything is fine
RESUME line# - should be easy, it's like a standard GOTO line#

I really have to enhance the tokenfile specs to make all these things configurable - otherwise the different basic dialects will kill me...
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version:

- Converting source to label-mode and back again to line# mode
- enhanced tokenfile structure
see Tokenfile_BasicV2.txt for more information. It now should be possible to configure each keyword if it is followed by line#, if the label conversion routine should indent or de-indent, how many bytes to read etc.
- some minor bugs squashed

In label-mode the single apostroph works like REM with one enhancement:
' #100,10
is a hint for converting back to line#, advicing the renumber process to start with line#100 and step 10 from here on. This way you can have your subroutines at "nice" line# even after conversion.

Code: Select all

   GOSUB MYPROC
   END
MYPROC:
   PRINT "SUBROUTINE"
   RETURN

->

10 GOSUB 30
20 END
30 PRINT "SUBROUTINE"
40 RETURN

Code: Select all

   GOSUB MYPROC
   END
' #100,5
MYPROC:
   PRINT "SUBROUTINE"
   RETURN

->

10 GOSUB100
20 END
100 PRINT "SUBROUTINE"
105 RETURN
UPDATE:
- PRINT@ now recognized as keyword
- when in label mode inserting a new line will indent as many spaces as the preceding line
- using backspace after the end of line now moves cursor left and eventually deletes the last non-space character of the line
- when you click "save prg" in label mode, the prgram will be converted back to line# mode in the background and saved, thus eliminating the need to always switch back and forth from label mode while editing and testing
- add a : before each ELSE when converting from label- to line# mode
- some minor bugfixes

ATTENTION: After the latest changes to keyword and line# recognation the renumber procedure is partially broken! This concerns replacement of line# in long lines with many commands, where sometimes the wrong numbers are replaced. Will be fixed soon!
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version:

- Fixed renumber and thereby conversion of line# to label as both use the same routine to detect jumps
- New menu "Compact source": when in line# mode, this tries to compact the source with squeezing as much commands per line as possible. Of course it considers lines which are jump destinations and IF statements which cannot be filled with further commands from following lines
- New menu switch "Crunch lines" which does the same as above when converting from label mode to line# mode. If checked the least possible number of lines will be generated, if not checked each source line will be a separate destination line

I checked the conversion routines with the source of Videopoker which nearly fills unexpanded VIC RAM. Loaded Videopoker.prg, converted line# to labels, saved as PRG with crunching. Now the program lines where numbered from 10 in steps of 10 instead of starting at line#0 with step of 1 and the composition of lines changed too due to automatic crunching. Afterwards I loaded it in Vice and could play as expected. This is no waterproof test but nonetheless I'm very satisfied.
I'm sure that there will be some problem with other sources, but at least it works with a non-trivial sample.
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

This version of BasEdit is working great, together with WimBasic.

Rewriting parts of Videopoker for WimBasic, and with the help of BasEdit, brought it back by 23 lines. The PRG has shrunk from 3104 to 2570 bytes.

My version runs in any memory configuration without modification, as long as the Wimbasic extension is used.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

That is really cool - Thanks for your feedback and your tests!
Had no time this weekend for further programming but hope that I can do some more enhancements to BasEdit next week.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version 0.92 uploaded

- version number in window title
- added ' (single apostroph) as REM, used by Exbasic/WimBasic
- better handling of REM/' while converting between label- and line#-mode, keeping spaces and not adding a space after REM
- '#[Znr],[Step] will not be transferred from label- to line#-mode as a comment
- ' comment will always be a single line, even after crunching
- REM comment will be the last command on a line after crunching

New version 0.93 uploaded
- INPUTLINE and INPUTFORM (Exbasic/WimBasic) no longer mistaken as INPUT while tokenizing

New version 0.94 uploaded
hopefully all overlapping keywords in existing keywordfiles handled:

Code: Select all

Standard Basic:
GO / GOSUB / GOTO
INPUT / INPUT# 
PRINT / PRINT#

Waterloo Structured Basic:
END / ENDIF / ENDLOOP / ENDPROC
ELSE / ELSEIF

Wimbasic/Exbasic:
PRINT@ (PRINT / PRINT#)
INPUTLINE / INPUTFORM (INPUT / INPUT#)
LET / LETTER

Basic V7 & V10:
DO / DOPEN

Basic V10:
FOR / FOREGROUND
New version 0.95 uploaded
- errors while de-indenting after NEXT fixed, if more NEXT's then FOR's appear the indent won't get before start-of-line anymore
- RESUME NEXT and DISPOSE NEXT don't count as NEXT anymore, therefore eliminating false de-indentation

New version 0.96 uploaded
- auto-detection of overlapping keywords like INPUT / INPUTLINE / INPUTFORM, now even with new keywordfiles these cases will be handled without any code changes

New version 0.97 uploaded
- fixed an error with ON A GOTO LBL100, LBL200, LBL300:[Some other commands] when converting labels back to line#

New version 0.98 uploaded
- first command line argument will be loaded as textfile (.txt extension) or Commodore basic file (all other extensions)

Remark: Anyone here who can tell me the opposite of indenting/indentation? De-indentation seems to be so wrong...
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version 0.99 uploaded

- some minor bugfixes
- added cross reference window for jumps and variables
-- jump list contains every jump destination and as childs the referring line#'s
-- variable lists contain every used variable and as childs the line#'s they are used in
- cross reference in short and enhanced format

New version 0.991 uploaded
- fixed a bug in cross reference generation that causes array variables to skip the rest of line, thereby missing all variables after the array
- added a = after line# in variable lists when variable gets assigned a value in that line (for example 10= meaning that in line 10 this variable gets assigned a value). Now you can see in whch lines a variable is changed!
-- Note that constructs in like 10 IFA=1B=2 which are valid in Exbasic/Wimbasic the B=2 gets not recognized as assignment. Please place a THEN before assignment.



short list:

Image

enhanced list:

Image
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version 0.992 uploaded
- enhanced StartAddress section in BasEdit.Ini
- When selecting "New Source" in context menu user will be prompted for starting address of Basic file
- Ability to (F5) Save&Run Basic file in emulator, new settings for emulator and commandline in BasEdit.Ini

Image
User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

This is very cool. I really like BasEdit's ability to crunch code and now the variable tracking. I know this would go beyond the name, but have you ever thought about adding a assembler, disassembler, and monitor to this gem. The all around programming tool for the Vic 20. And heck, while I'm wishing, throw in a graphics editor for characters and bitmap screens. 8)

Anyhow, keep up the great work.
Rob
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Thanks for your kind words. :oops:

An integrated character editor and a screen editor are features I'm thinking about, together with the ability to put UDF and Basic-code together in one file for ease of loading at a VIC.

Another cool feature would be some Basic extensions only in the editor which will be converted to standard Basic V2 commands on save, something like WHILE/WEND or DO/LOOP, IF/ELSE/ENDIF etc. So one could concentrate more on the algorithm, get better readable sources and nonetheless be able to run this on a stock VIC.

And in fact I am thinking about an assembler feature. I have my own, self-written 2-pass macro assembler, it's in a different Basic dialect (Purebasic) but shouldn't be too difficult to convert. I won't promise anything, but at least there is a possibility...

Dissassembler and monitor would require deep interaction with VICE or any other emulator, I think the built in monitor of Vice must be enough.

You see, there are lots of possibilities and opportunities within BasEdit, maybe this will result in a future CBMEdit :roll:

For the moment I'm polishing the existing features, adding some little twists and making a 1.0 release.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

GreyGhost wrote:And heck, while I'm wishing, throw in a graphics editor for characters and bitmap screens. 8)
@Schlowski: If you need detailed information about the picture file format shared by MINIGRAFIK, and MINIPAINT, just ask me. ;)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version 1.0 uploaded
- added context menu item "Insert text from clipboard" - this enables copying from other applications into BasEdit
- added context menu item "Convert clipboard to uppercase" to automatically make any text uppercase when inserting (because BasEdit assumes basic commands in uppercase)
- added context menu item "Save and Run (F5)..." which saves the basic file and starts an emulator with the basic prg as command line parameter
-- new settings in BasEdit.Ini

Code: Select all

      ' Emulator
      Emu=.\WinVICE-2.2-x86\xvic.exe
      ' Commandline parameters for Emulator
      ' %F=full path to PRG-file
      EmuParams=%F
-- with these settings any other emulator should be possible to be started, too
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version 1.01 uploaded
- added button "->Clipboard" in cross reference window. Copies the complete reference lists into clipboard with linefeeds and tabs so that you can insert the cross reference lists in Excel or another Texteditor for further editing or printing.
- added context menu item "Sort..." which sorts the source regarding line numbers. So if you have after editing line numbers 10,5,15,20,30,25,40 a simple click will sort this to 5,10,15,20,25,30,40
Post Reply