Virtual Basic a different approach to code Applesoft Basic (for Apple II computers)

With Virtual Basic Editor (see pict above) and Virtual Basic rules we can improve the way to code Applesoft Basic.

Virtual Basic is copyleft !
Copyright © 2011-2016, Andres Lozano aka Loz
Copyleft: This work is free, you can redistribute it and / or modify it under the terms of the Free Art License. You can find a copy of this license on the site Copyleft Attitude well as http://artlibre.org/licence/lal/en on other sites.

Virtual Basic is Applesoft basic, all commands and operators are available, only the way to write your code change.

In Virtual Basic you don't need to number lines, the links between calls (goto, gosub) and code parts aren't numbered, indeed you use names @xxxx in order to go to subscript and £xxxx in order to indicate the place of the subscript. So you can add, delete and move parts of your code freely. When you convert Virtual Basic with baz-to-bas.py (python) it will numbers lines for you.

Virtual Basic Applesoft Basic
£test
    if i > 10 then gosub @alert
    i= i + 1:goto @test
	£alert
		print i;" is greater than 10"
    return  
 end
10 REM - APPLESOFT - BASIC
20 REM->TEST
30 IF I > 10 THEN GOSUB 60
40 I= I + 1:GOTO 30
50 REM->ALERT
60 PRINT I;" I IS GREATER THAN 10"
70 RETURN
80 END

And Virtual Basic allows you:

to add comments everywhere in your code using braces {xxxx}

bp%= bp%{mainLoop} + 1

to indent code

for b1=0 to 23
	for b2=0 to 59
		for b3=0 to 59
			home
			h$= str$(b1)
			if b1 < 10 then h$= "0"+h$
			m$= str$(b2)
			if b2 < 10 then m$= "0"+m$
			s$= str$(b3)
			if b3 < 10 then s$= "0"+s$
			print "time is ";h$;":";m$;":";s$
			for b4=0 to 500
next:next:next:next

to import Virtual Basic scripts already written

===insert path/head.baz===

to ignore lines using # ignored code

# hidden code

or using

[
	ignore
	multiple
	lines
]

to have 2 rem, rem * comment level to save space

rem mostly preserved
rem * often preserved

to have low case / up case in your scripts, up case is automatically converted

to split code into sections (divisions)

section main program
   £begin
   rem * my basic program
   r{loops}= 100
   for i= 1 to r
      print i{increase};" hello world"
   next
   if r < 99 goto @begin
   print "stop"
closesection
end

Virtual Basic allows you to compact the code and save memory space.

Virtual Basic Applesoft Basic compressed
section main program
	£begin
	rem maximum = 100
	mx = 100
	rem reset screen to black
	home
	 
	rem first loop
	for i{increase}= 1 to mx{maximum}
		rem cursor position
		vtab(12):htab(1)
		print "loops -> ";i;
	next
	
	rem second loop to make a circle
	rem switch on graphic screen
	hgr
	rem circle = 2 * pi
	ci{circonference}= 2 * 3.141516
	rem number of points
	s{step}= ci / 12
	rem center of max width
	xo= 279 / 2
	rem center of max height
	yo= 159 / 2
	rem radius of the circle
	r= 50
	for i{increase}= 0 to ci{circonference} + 0.1 step s{step}
		rem multiply radius by sin(increase)
		v1= r * sin(i)
		rem add to center
		x= xo + v1
		rem multiply radius by cos(increase)
		v2= r * cos(i)
		rem add to center
		y= yo + v2
		rem hplot draw a point at x,y
		rem first point i = 0
		if i = 0 then hplot x,y
		rem next points
		if i > 0 then hplot to x,y
	next
	rem waiting for a keystroke
	get s$
	text:home
closesection
end
10REM-VIRTUALBASIC.ORG-ONLINE-TOOL.BAS-07/03/2011-22h23
40MX=100
60HOME
80FORI=1TOMX
100VTAB(12):HTAB(1)
110?"LOOPS -> ";I;
120NEXT
150HGR
170CI=2*3.141516
190S=CI/12
210XO=279/2
230YO=159/2
250R=50
260FORI=0TOCI+0.1STEPS
280V1=R*SIN(I)
300X=XO+V1
320V2=R*COS(I)
340Y=YO+V2
370IFI=0THENHPLOTX,Y
390IFI>0THENHPLOTTOX,Y
400NEXT
420GETS$
430TEXT:HOME
440END

With Virtual Basic to write Applesoft Basic scripts become easy and very productive.