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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 265
» Latest member: queensizebed
» Forum threads: 944
» Forum posts: 6,311

Full Statistics

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

Latest Threads
Tire Shredder suppliers
Forum: News
Last Post: hhent45
Today, 01:31 AM
» Replies: 0
» Views: 4
Water Faucet suppliers
Forum: News
Last Post: hhent45
Today, 01:31 AM
» Replies: 0
» Views: 0
China Solar Flood Light 1...
Forum: News
Last Post: hhent45
Today, 01:30 AM
» Replies: 0
» Views: 1
Automatic Plastic Bag Sea...
Forum: News
Last Post: hhent45
Today, 01:29 AM
» Replies: 0
» Views: 2
N95 Standard Nose Mask ma...
Forum: News
Last Post: hhent45
Today, 01:29 AM
» Replies: 0
» Views: 0
Automatic Filling And Sea...
Forum: News
Last Post: hhent45
Today, 01:28 AM
» Replies: 0
» Views: 0
cheap Reflective Elastic ...
Forum: News
Last Post: hhent45
Today, 01:28 AM
» Replies: 0
» Views: 0
Custom heat transfer prin...
Forum: News
Last Post: hhent45
Today, 01:27 AM
» Replies: 0
» Views: 1
FDA Medical KN95 Mask Non...
Forum: News
Last Post: hhent45
Today, 01:26 AM
» Replies: 0
» Views: 3
Low Cost Franchises With ...
Forum: News
Last Post: hhent45
Today, 01:25 AM
» Replies: 0
» Views: 2

 
  Using --debug-array with arrays passed to functions
Posted by: georgeo - 03-09-2021, 01: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 - 03-08-2021, 09: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 - 03-08-2021, 01: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 - 02-27-2021, 10: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 - 02-27-2021, 04: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 - 02-27-2021, 12: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

  FYI FUNCTIONs and RETURN value
Posted by: RandomiserUsr - 02-27-2021, 12:07 PM - Forum: Help & Support - Replies (4)

I have seen a problem where if you call a function without a RETURN 0 with no return value in FUNCTION declaration e.g.

FUNCTION UFNprintText(printText$ AS STRING )

Sometimes the function will just crash the ZX Spectrum emulator

Adding a RETURN 0 makes it work.

Just thought you might know this?

Print this item

  DIM a$(100,10) possible bug?
Posted by: RandomiserUsr - 02-26-2021, 08:03 PM - Forum: Help & Support - Replies (2)

Hi, 

I have been developing a game and one of thing things I wanted to is build up a string and print it out but the issue I have is that I can't do the following code in zxbc :-


Code:
DIM a$(100,10)
LET a$(1) = "Line 1"
PRINT a$(1)

But I can do the above in a ZX Spectrum emulator.

I know the solution is to use a$(1,1) (Ignore the zero array start)

PS Brilliant compiler!! 

Thanks,
Ken

Print this item

  Value of FastPlot library
Posted by: patters - 01-28-2021, 06:39 PM - Forum: Help & Support - Replies (9)

Is the FastPlot library really going to be faster than a compiled PLOT instruction? Since you've optimised your own PRINT implementation, I would assume that PLOT and DRAW compile to pretty lean machine code do they not? I did some very basic testing comparison of filling using DRAW commands versus looping through FastPlots instead and it seemed roughly the same. Is it perhaps that some libraries are old, and now the compiler is as good with native commands in terms of performance?

Print this item

  PRINT AT 22,0
Posted by: patters - 01-27-2021, 06:57 PM - Forum: Help & Support - Replies (2)

Is it normal that the entire screen scrolls every time I print at line 22 - not even filling the line? Surely it should behave like the other lines, no? Or else it's not much of an improvement over Sinclair BASIC's PRINT #0; AT 1,0;

Print this item