After doing some more changes to my project, zxbc started to complain about "Can't convert non-numeric value to string at compile time", check it out:
Code:
reveni.bas:46: error: Can't convert non-numeric value to string at compile time
reveni.bas:44: error: Can't convert non-numeric value to string at compile time
The second error is signaling a line that... is empty! The first error refers to the following source:
Code:
clrscr()
I think this means that the compiler gets somehow confused about something. I'm attaching the project.
Thanks,
-- Baltasar
$ python ~/bin/zxbasic/zxbc.py --tap --BASIC --autorun reveni.bas
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/keys.bas:50: warning: [W150] Parameter 'scancode' is never used
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/print64.bas:20: warning: [W150] Parameter 'characters' is never used
cmd.bas:41: warning: [W150] Parameter 'cmd' is never used
io.bas:222: warning: [W100] Using default implicit type 'float' for 'current_loc'
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/keys.bas:51: warning: [W190] Function 'MultiKeys' should return a value
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/keys.bas:72: warning: [W190] Function 'GetKeyScanCode' should return a value
objs.bas:88: warning: [W170] Function 'get_objs_in' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/keys.bas:50: warning: [W170] Function 'MultiKeys' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/keys.bas:71: warning: [W170] Function 'GetKeyScanCode' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:29: warning: [W170] Function 'mid' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:40: warning: [W170] Function 'left' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:51: warning: [W170] Function 'right' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:98: warning: [W170] Function 'strpos' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:124: warning: [W170] Function 'ucase2' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:174: warning: [W170] Function 'ucase' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:249: warning: [W170] Function 'ltrim' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:275: warning: [W170] Function 'rtrim' is never called and has been ignored
/home/baltasarq/bin/zxbasic/src/lib/arch/zx48k/stdlib/string.bas:304: warning: [W170] Function 'trim' is never called and has been ignored
util.bas:47: warning: [W170] Function 'testMultiplyStr' is never called and has been ignored
util.bas:57: warning: [W170] Function 'testFormatStr' is never called and has been ignored
Traceback (most recent call last):
File "/home/baltasarq/bin/zxbasic/zxbc.py", line 12, in <module>
sys.exit(zxbc.main()) # Exit
^^^^^^^^^^^
File "/home/baltasarq/bin/zxbasic/src/zxbc/zxbc.py", line 110, in main
optimizer.visit(zxbparser.ast)
File "/home/baltasarq/bin/zxbasic/src/api/optimize.py", line 199, in visit
return super().visit(node)
^^^^^^^^^^^^^^^^^^^
File "/home/baltasarq/bin/zxbasic/src/api/optimize.py", line 56, in visit
return super().visit(ToVisit(node))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/baltasarq/bin/zxbasic/src/ast/ast.py", line 42, in visit
stack.append(last.send(last_result))
^^^^^^^^^^^^^^^^^^^^^^
File "/home/baltasarq/bin/zxbasic/src/api/optimize.py", line 423, in visit_FOR
if from_ > to_ and step_ > 0:
^^^^^^^^^^^
TypeError: '>' not supported between instances of 'SymbolID' and 'SymbolID'
I was compiling my program when the compiler claimed (correctly) that there was an error in my code:
Code:
util.bas:105: error: Function 'FormatStr' takes 3 parameters, not 1
This message was correct, but instead of signaling the file name and the line where the error was present, it was showing the line number and the file name of where the function was defined!
It also messes with the line number, which corresponds to where the error happened, not where the function was defined. In my case, the error happened at line number 105 of player.bas, calling function FormatStr() defined in line number 39 of util.bas.
I think it would be better to expose both pieces of information, maybe this way:
Code:
player.bas: 105: error: Function 'FormatStr' takes 3 parameters, not 1
util.bas:39: error: Function 'FormatStr' defined here.
' Duplicates the string for times times.
' For instance, MultiPlyStr( "0", 3 ) ' -> "000"
' times must be between 1 and 127
function MultiplyStr(ByVal s as string, ByVal times as byte) as string
dim toret as string = ""
if times > 0
for i = 1 to times
toret = toret + s
next
end if
return toret
end function
' Returns a formatted string with the number n
' and enough preceding chars (the ch parameter),
' so that the length of the string is w or more.
' for instance, FormatStr(15, 4, "0") ' -> "0015"
' w must be between 1 and 127.
function FormatStr(ByVal n as integer, ByVal w as byte, ByVal ch as string) as string
dim toret as string = str( n )
dim len_prefix as byte = w - len( toret )
return MultiplyStr( ch( 0 ), len_prefix ) + toret
end function
my THE SPECTRUM has arrived for 99 euros in Germany.
a great device.
I set it to spectrum maschine 128k.
my programs-128k from ZX Basic run wonderfully.
also the bank programs in ZX Basic for the 128k with the bank switching.
greetings
this interrupt ist ok with "THE SPECTRUM"
----------------------------------------------
Code:
' Example of the use of the IM2 library
' Including the IM2 library
#include "IM2.bas"
' We declare two variables to use inside IM2CallMyRoutine
' These variables must be global
' Time wasting counter
DIM im2_Counter AS UInteger
' Height of the horizon
DIM im2_Horizon AS UInteger = 400
' We call the subroutine Main
Main()
' - Main subroutine ---------------------------------------
SUB Main()
CLS
PRINT AT 23,0;"q - Up, a - Down, s - Stop";
PRINT AT 0,0;"Height of the horizon:";
' We configure and start up the interruptions.
IM2Start(@MyInterruptRoutine)
' Infinite loop
DO
' Print the current horizon height
PRINT AT 0,23;im2_Horizon;" ";
' If we press "q", we raise the horizon.
IF INKEY$ = "q" THEN
' We raise it as long as it is not 0
IF im2_Horizon > 0 THEN
' Going up means less pause
im2_Horizon = im2_Horizon - 1
END IF
' Pressing "a" lowers the horizon.
ELSEIF INKEY$ = "a" THEN
' Going down is to pause more
im2_Horizon = im2_Horizon + 1
' Pressing "s" stops the interruptions.
ELSEIF INKEY$ = "s" THEN
IM2Stop()
RETURN
END IF
LOOP
END SUB
' - This is our routine which is called at every interruption
' We can't do a lot of things inside
' Do not define local variables, do not use ROM,
' not to dawdle too much...
SUB FASTCALL MyInterruptRoutine()
' The sky is cyan
BORDER 5
' We wait to change from heaven to earth
FOR im2_Counter=0 to im2_Horizon
NEXT im2_Counter
' The land is green
BORDER 4
END SUB