The following warnings occurred:
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval




Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 277
» Latest member: Elemento26
» Forum threads: 1,087
» Forum posts: 6,490

Full Statistics

Online Users
There are currently 134 online users.
» 0 Member(s) | 132 Guest(s)
Bing, Google

Latest Threads
GuSprites
Forum: Help & Support
Last Post: zedex82
2026-06-19, 06:39 PM
» Replies: 2
» Views: 355
New video Couse / Nuevo c...
Forum: News
Last Post: Duefectu
2026-04-29, 11:02 PM
» Replies: 0
» Views: 2,698
location of heap manageme...
Forum: Help & Support
Last Post: boriel
2026-03-07, 12:13 AM
» Replies: 1
» Views: 745
non-paged supervisor code...
Forum: Help & Support
Last Post: sdo303
2026-02-20, 06:38 PM
» Replies: 8
» Views: 1,847
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,742
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 2,538
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 1,395
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 1,478
Hall of Fame - Include fo...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-28, 03:48 PM
» Replies: 0
» Views: 819
[SOLVED] Array layout bug...
Forum: Bug Reports
Last Post: Zoran
2025-10-25, 05:48 PM
» Replies: 2
» Views: 1,539

 
  Understanding memory layout
Posted by: georgeo - 2021-03-13, 12:11 PM - Forum: Help & Support - Replies (2)

Hi everyone,



I am seeing some strange memory problems when compiling a reasonably large program, which probably means I don't understand how the compiler organises memory.




Specifically, I have a program that is around 28kb in size, including a 1kb heap. Depending on the origin value I use, the program will either work or crash, but not as you might expect.




Initially, I set the origin of the code to 26000 (that is, "--org 26000") and this worked fine for a time. However, when my program reached a certain length (from memory, around 25kb), I started to see odd behaviour (corrupted strings and Out Of Memory errors). I tried increasing the heap size (to 2kb, 3kb, 4kb, 5kb, 6kb), though this didn't help. I then tried changing the origin to 28000 and then everything was fine again.




A little later on, with some more code added, I started to see problems again, so I again tried increasing the origin address--now to 29000 and again all is fine.




I'm confused because:




  1. the program isn't that big, fitting in between address 29000 and 57,353 (right now), so well clear of user-defined graphics and any Sinclair BASIC workspaces
  2. I would have expected that lowering the origin address would be more likely to help, if there was a lack of memory, rather than increasing it.

I checked the memory map (produced with '--mmap') and, indeed, symbols are defined for addresses between 29,000 and 57,247, so that all looks correct.



Can anyone suggest what is going on here? Thanks in advance,

Print this item

  Print42 library throws error with --explicit option
Posted by: georgeo - 2021-03-13, 11:59 AM - Forum: Help & Support - Replies (5)

Hi everyone,

I'd like to use --explicit to force me to define all variables before using them, to reduce the risk of bugs. However, I see an issue because my program uses the Print42 library and it contains a definition that seems to violate the --explicit option.

Specifically, if you try to compile a program that includes Print42 library, using --explicit, you will see an error something like:

Code:
C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:16: error: Undeclared variable "printAt42Coords" C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:17: error: Undeclared variable "printAt42Coords"

I considered updating the library source, so that printAt42Coords is defined. However, printAt42Coords is a code label, not a normal variable. The compiler complains because the label is dereferenced with an @printAt42Coords operation to work out the address at which to store the current coordinates:

Code:
SUB printat42 (y as uByte, x as uByte)     POKE @printAt42Coords,x     POKE @printAt42Coords+1,y END SUB ... printAt42Coords: ...

I don't know what type of variable printAt42Coords is, so can't add a 'dim' statement to define it. I tried defining it as a 'uinteger', but then the compiler complains when it tries to use as a label "error: identifier 'printAt42Coords' is a var, not a function"

Anyone know how to work around this?

Thanks in advance,

Print this item

  Understanding scope of variables
Posted by: georgeo - 2021-03-11, 02:51 PM - Forum: Help & Support - Replies (5)

Hi everyone,

In ZXBASIC, is this a valid program?

Code:
function myFunction( name$ as string ) as uinteger     dim length, n as ubyte     dim total as uinteger = 0     length = len(name$)     if length=0 then return total     end if     for n = 0 to length-1 total = total + code(name$(n))     next n         return total end function REM Main program dim n as ubyte dim ans as uinteger n = 14 ans = myFunction("Hello") print "Answer = " + str$(ans) print "n = " + str$(n) stop

I have a variable labelled 'n' in both the top-level program and a function. I believe, in the function, 'n' is a different, locally defined variable, which is deleted when the function ends.

Would the same work, if I replaced the function with a subroutine (accepting I couldn't return an answer in the same way)?

I ask as I am seeing unexpected behaviour in my program (not the one above, a much longer program) and one possibility is that I'm using the same variable names for different entities in both the top-level program and subroutines.

Thanks in advance for any help

Print this item

  Dim At Issue? (1.15.0-beta4)
Posted by: Ljg701 - 2021-03-09, 09:07 PM - Forum: Help & Support - Replies (4)

Hello Boriel,

The following array initiation code I don't think is initiating the array data at the correct address. In the example below, the peek returns a value of 255 rather than 1, also @test doesn't return a value of $c000  (Version  1.15.0-beta4 + NextBuild)

Code:
'!ORG=24576 '!OPT=4 dim test(0 to 3) as ubyte => {1,2,3,4} at $C000 'this should return 1 print at 0,0;peek($c000) do loop until inkey$<>""

Print this item

  Using --debug-array with arrays passed to functions
Posted by: georgeo - 2021-03-09, 02:11 PM - Forum: Help & Support - Replies (4)

Hi everyone,

I would like to use the --debug-array option to check I have not used out-of-range array indices in my program. However, it appears that I need to give the compiler more information, to use the option in a program that passes arrays as function arguments.

For example, the following simple program appears to compile/ run correctly:

Code:
function pickString$( choice as ubyte,  listOfStrings() as string ) as string     return listOfStrings(choice) end function dim myString$(3) as string myString$(0) = "Zero" myString$(1) = "One" myString$(2) = "Two" myString$(3) = "Three" dim n as ubyte for n=0 to 3     print pickString$(n, myString$) next n stop

--but the compiler generates an error if I try to compile with the --debug-array option:

Code:
zxbc -t -a -B --debug-array array_bounds_ex.bas Traceback (most recent call last):   File "c:\opt\zxbasic-1.14.0\zxbasic\zxbc.py", line 10, in <module>     sys.exit(libzxbc.main())  # Exit   File "c:\opt\zxbasic-1.14.0\zxbasic\src\libzxbc\zxbc.py", line 246, in main     func_visitor.start()   File "c:\opt\zxbasic-1.14.0\zxbasic\src\arch\zx48k\translator.py", line 1401, in start     self.visit(f)   File "c:\opt\zxbasic-1.14.0\zxbasic\src\ast\ast.py", line 35, in visit     stack.append(last.send(last_result))   File "c:\opt\zxbasic-1.14.0\zxbasic\src\arch\zx48k\translator.py", line 196, in visit_ARGLIST     upper = node.parent.entry.bounds[i].upper   File "c:\opt\zxbasic-1.14.0\zxbasic\src\symbols\boundlist.py", line 29, in __getitem__     return self.children[key]   File "c:\opt\zxbasic-1.14.0\zxbasic\src\ast\tree.py", line 40, in __getitem__     return self._children[key] IndexError: list index out of range

I imaging the problem is that the compiler can't work out the array bounds within the function, unless I tell it. Anyone know if I can modify the source, so array-bound checking will still work?

Thanks in advance,

Print this item

  SAVE and LOAD commands - help!
Posted by: RandomiserUsr - 2021-03-08, 10:04 PM - Forum: Help & Support - Replies (3)

Hi

I have been trying to use the SAVE command to save the data whilst the program is running, i.e. SAVE "GAME" DATA
which I though would save all of the variables in the program?  *Save to Virtual Cassette tape*

And then I thought "All I need to do next is " LOAD "GAME" DATA 
and it would restore the entire game's data but it just crashes after it says "Bytes: GAME" 

I am sure there is something else that needs doing but can't recall this (80's memory is not as good as it should :-)  )

thanks in advance

Print this item

  Dealing with "Out of Memory" errors
Posted by: georgeo - 2021-03-08, 02:09 PM - Forum: Help & Support - Replies (6)

Hi everyone,

I am relatively new to ZXBASIC, though think I have mostly got the hang of things and am using it to write a new game.

I am seeing intermittent Out of Memory issues (when compiling with --debug-memory), which I believe means I am running out of heap space. However, I've tried increasing the heap quite significantly (e.g., up to 8 kb) with little effect. I've also tried reducing the dependence on string arrays/ variables, in case this was the problem.

If I see an intermittent Out of Memory error mid-way through a program, long after most variables should have been defined, will it be heap-related or could it be something else?

Any suggestions for debugging my code, or properly sizing the heap, would be much appreciated.

Thanks in advance,
Georgeo.

Print this item

  String Arrays and memory
Posted by: RandomiserUsr - 2021-02-27, 11:51 PM - Forum: Help & Support - Replies (4)

Hi,

I wonder if someone could help me?

I have started writing a game but it uses a lot of String arrays.
The problem is I am compiling okay but on the screen things are missing where text should be.

I have compiled it using :-

Code:
zxbc MainEngine.bas --tzx --BASIC --autorun  --heap=6000 --optimize 2  --org=25000 --mmap=memory_map.txt
I am not sure where the issue but let me know if you need more information

Thanks
Ken

Print this item

Thumbs Up String Arrays problems "nonsense in Basic" - fixed
Posted by: RandomiserUsr - 2021-02-27, 05:12 PM - Forum: Help & Support - No Replies

Hi, I am looking at how to store a string of descriptions into an array.
Sounds straight forward enough, so should be something like


Code:
DIM A$(100,200) LET A$(1,1)= "This description 1 : The quick brown fox jumps over the lazy dog." LET A$(2,1)= "This description 2 : The quick brown fox jumps over the lazy dog." LET A$(3,1)= "This description 3 : The quick brown fox jumps over the lazy dog." LET A$(4,1)= "This description 4 : The quick brown fox jumps over the lazy dog." [size=small][font=Tahoma, Verdana, Arial, sans-serif]PRINT A$(1,1)[/font][/size]

So it should print.

This description 1 : The quick brown fox jumps over the lazy dog.

It is being compiled with

Code:
zxbc aTest.bas --tzx --BASIC --autorun  --debug-array
But all I get when I run it in the ZX Spectrum emulator is 

C Nonsense in BASIC, 30:1

Any ideas why?
I think this is down to memory?

thanks
Ken

UPDATE: 
It seems that all I needed to do is declare A$(100,200) as A$(100) and access it via print A$(1) and that is it - nice to fix things along the new road :-)

Print this item

  FUNCTIONS again
Posted by: RandomiserUsr - 2021-02-27, 01:15 PM - Forum: Help & Support - Replies (2)

If you compile the following code 

FUNCTION A(text as STRING)

Print B("Test")

RETURN 0
END FUNCTION


FUNCTION C(text as STRING)
Print B("Test")
RETURN 0
END FUNCTION

FUNCTION B(text as STRING)
Print ("Test")
RETURN 0
END FUNCTION


you will get
inputmud.bas:137: error: 'B' is neither an array nor a function.
inputmud.bas:135: warning: [W150] Parameter 'text' is never used
inputmud.bas:144: warning: [W100] Using default implicit type 'float' for 'C'
inputmud.bas:144: error: 'B' is neither an array nor a function.
inputmud.bas:143: warning: [W150] Parameter 'text' is never used
inputmud.bas:149: warning: [W100] Using default implicit type 'float' for 'B'
inputmud.bas:148: warning: [W150] Parameter 'text' is never used


but moving function B above like below compiles okay

So I guess it's a TOP Down design where the functions in the same .BAS should be ordered

FUNCTION B(text as STRING)
Print ("Test")
RETURN 0
END FUNCTION
FUNCTION A(text as STRING)

Print B("Test")

RETURN 0
END FUNCTION


FUNCTION C(text as STRING)
Print B("Test")
RETURN 0
END FUNCTION



Great tool

Thanks
Ken

Print this item