07-07-2014, 04:37 PM
(This post was last modified: 01-18-2021, 01:40 PM by boriel.
Edit Reason: Fix code to follow the new syntax
)
boriel Wrote:Darkstar Wrote:This line sadly still bombs on me:Please try now, Version 1.4.0-s1880, and tell me if SAVE now works (silly bug: I just forgot that translation).
const BasePtr as uinteger = 32768
save "Contents"code BasePtr, 25
It works without a hitch now, thank you for fixing this as I am not totally blocked as I was before.
The nested scopes were a good addition me thinks.
I did write somthing else and I am including it below.
Code:
'dim MyArray(0 to 4) as string => {{"ABCDE","ABCDE","ABCDE","ABCDE","ABCDE"} ' each element is 5 letters or bytes in length
const BasePtr as uinteger= 32768 ' 32K
dim MyArray(0 to 4) as string
dim i as ubyte
dim Key as string
' init the array
for i = 0 to 4
MyArray(i) = "ABCDE" ' 5 in length
next i
' I had to init the array here to make sure each element is five bytes in length and I could not do it through the dim line above
' so this is just another workaround. I had more options in the menu but I took them out but they allowed for meaningful content creation.
' The content was created by those options so I could get away in this instance with a dumb fill of the array but what if I want to fill the
' array with something meaningful right from the get go and perhaps with a variable length in the elements? No DATA lines and no DIM and even
' more workarounds to account for the variable length. Ugly ugly hacks. It could even FORCE me to go to the ASM level.
MenuEntryPoint1:
paper 7
flash 0
bright 0
over 0
inverse 0
ink 0
border 6
MenuEntryPoint2:
cls
print
print "1 Load file"
print "2 Save file"
print
print "3 Quit"
do
Key = inkey
loop until Key = "1" or Key = "2" or Key = "3"
if Key = "3" then
randomize usr 0
end if
cls
if Key = "1" then
gosub LoadFile
end if
if Key = "2" then
gosub SaveFile
end if
'goto MenuEntryPoint2
' This is how it should read or to go to Point2 instead of Point1 but because the SAVE command messees up the color
' then this workaround was the only option and it alters the program flow.
goto MenuEntryPoint1
' The save message itself or the ROM based message gets displayed in yellow paper and that I also consider a bug but I did not look into
' a yet another workaround for it.
' All of these workarounds sure mess up the code and that is why I did not look into it for I have had it with unfriendly workarounds and they just
' make things way more complex than they have to be.
' But the good news is that due to some recent fixes I can eliminate some of them but far from all of them and I can't eliminte the linier array workaround either
' as of now but that is one of the things I took out of this BAS file.
' I do not want to share ugly hacks.
LoadFile:
print "Loading file"
print
load "File"code BasePtr, 25
' Do lots of stuff that has been deleted from this BAS file
return
SaveFile:
print "Saving file"
print
' Do lots of stuff that has been deleted from this BAS file
save "File"code BasePtr, 25
return