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 76 online users.
» 0 Member(s) | 74 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

 
  Compiler optimization setting
Posted by: patters - 01-27-2021, 06:35 PM - Forum: Help & Support - Replies (2)

Is it a good idea to use -O3? I know typically there are trade-offs - like loop unrolling can make code bigger in order to become faster. Is there much of a difference for ZX Basic between -O2 and -O3? Am I better off sticking to the default -O2 since it's more tried and tested?
Or since I'm not yet running into memory limits should I use -O3 while I can?

Print this item

  Mute compiler warnings for included libraries
Posted by: patters - 01-26-2021, 03:24 PM - Forum: Library - Replies (1)

Every time I compile I get a big wall of text of warnings about unused variables and functions in libraries that are included in my program (input.bas, attr.bas and its own includes, HRPrint.bas, fastTrig.bas). Could such warnings for libraries be muted by default perhaps and make them elective for library debugging, or at least allow me to exclude them in my build script? I didn't write these pieces of code, so I'm not interested in these warnings. However if I mute all warnings then I could miss an issue with my own code. Even with warnings enabled I have missed many genuine warnings because they were drowned out by the noise (variable unused is the classic one - when a name has been mistyped or the capitalisation is wrong somewhere in the listing).

Print this item

Bug Screen attribute statement ignored on SUB exit (*solved*)
Posted by: patters - 01-26-2021, 12:22 PM - Forum: Bug Reports - Replies (5)

If I have multiple attribute changes on a single line, the last one is ignored on exit from a SUB.
Consider this example which exposes the problem:

Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"

For the first example print, it should be bright but it isn't.
The second example print should have red ink but it doesn't.
I thought I was going mad until I found this.

If I substitute another command in this last statement position of the SUB (like a PRINT for instance) then that works. It's only attribute assignments that seem to fail. Also, if I insert another command before the END SUB, then it all works as expected. e.g. the below code works fine:
Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
    BEEP 0.1,60
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
    BEEP 0.1,60
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"




On further testing, the issue is not related to multiple colon-separated statements on the same line. With the following code the compiler also loses the last statement in each Sub and fails to work as expected:
Code:
SUB screenAttributes
    PAPER 3
    INK 7
    BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4
    BRIGHT 1
    INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"

Print this item

  Creating a populated array of strings
Posted by: patters - 01-26-2021, 01:07 AM - Forum: Help & Support - Replies (1)

Hi Boriel,

I notice that I cannot do the following:

Code:
DIM stringArray(2) AS STRING => {"apples", "oranges", "pears"}

The compiler returns "error: Initializer expression is not constant."

Digging on this forum reveals a post from 2009, in which you state this is not possible because string lengths are dynamic. Is this still the case? As you posted in that thread, it ought to be simple to just have the compiler run a bunch of individual LET assignments, but it's a bit ugly to have to type them out.

Thanks,

Patters

Print this item

  ZX Basic syntax highlighter for Sublime Text
Posted by: patters - 01-23-2021, 03:12 AM - Forum: ZX Basic Compiler - Replies (2)

Hi all,

I have created a syntax highlighter for ZX BASIC for the editor Sublime Text. It's an excellent code editor which, like ZX BASIC itself, is available for Linux, Mac OS, and Windows.

Enjoy!

https://github.com/patters-syno/zx-basic-syntax


[Image: example.jpg?raw=true]

Print this item

  Clearing an array
Posted by: patters - 01-19-2021, 10:47 PM - Forum: Help & Support - Replies (6)

What is the recommended way to reset an array's contents? Do we have to run a FOR loop from 0 TO UBOUND and clear it element by element, or is there a neater way?
I see that the following doesn't work:

Code:
arrayName={}

Print this item

  Custom TAP loader with SCREEN$
Posted by: patters - 01-17-2021, 06:24 PM - Forum: Help & Support - Replies (6)

I have a Sinclair BASIC loader for my game which will CLEAR 32767, load a SCREEN$, LOAD ""CODE, and finally RANDOMIZE USR 32678. I have assembled the loader and the SCREEN$ into a TAP file - but how to I get zxbc.py to append its output to this TAP file? I can't seem to get it to work.

When I try:

Code:
./zxbc.py -t --append-binary ../loader+scr.tap ../arti12.bas
 
I get a file arti12.tap as expected but it doesn't load the machine code. If I browse the TAP file in Fuse emulator I see that zxbc.py appears to have prepended an additional self-contained TAP file into the loader TAP file, rather than appended the binary data. Am I doing this wrong, or is this a bug?

I have managed to work around the issue by producing a .bin file instead, and then Fuse's 'Import Binary Data' option and then saving the memory range back out to the mounted TAP file - but it would be much nicer to automate that with zxbc.py if possible.

Thanks

Print this item

  Documentation frequently offline
Posted by: patters - 01-13-2021, 12:01 PM - Forum: Documentation - No Replies

Hi,

I have been frequently referring to the ZX Basic documentation while I have been programming. I find that at random (but multiple times a day) the search feature on the wiki returns no results for a short period which is quite frustrating. It's happened again right now. During though outages, luckily I can consult the markdown files on GitHub. However, they don't have a search function, which is useful so I do prefer the wiki.

I also notice that the boriel.com landing site frequently drops off the Internet late at night too. Can you perhaps set up some kind of host monitoring to determine just how big a problem this is, or maybe raise a support ticket with the webhost?

Thanks,

Patters

Print this item

Bug First RND call is ignoring RANDOMIZE, subsequent calls are fine (*solved*)
Posted by: patters - 01-13-2021, 02:38 AM - Forum: Bug Reports - Replies (3)

I have noticed while testing my program that the very first random number is always the same when the compiled program is loaded into an emulator. Subsequent ones are indeed random.

That first result is normal - you might think - because RND will be invoked at the same number of ticks after power-on each time. However, I use RANDOMIZE after an INPUT (which won't always be submitted at a consistent time by the user) before the first RND in the program is requested, so this should not happen. I presume this is a bug because after the first RND, it behaves as normal. If I deliberately insert a dummy RND before the RND values I need, then my program runs with the expected randomness.

Simple test case which demonstrates the issue:

Code:
#include <input.bas>

DIM i$ AS STRING
CLS
i$=INPUT(1)
RANDOMIZE
PRINT INT (RND*100) 'this number is consistent every time the emulator is launched with the tap file
PRINT INT (RND*100) 'this number will be random

When I run the tap file in Fuse on Mac OS I usually get 60 for the first random number. Very occasionally I get 61 though, so that may help for debugging. It's always those two values though. The second number will be in the range 0-99 as expected.

This issue is present in release version 1.14 and in 1.14beta9

Print this item

Bug Dim Array At Constant Issue (*solved*)
Posted by: Ljg701 - 01-12-2021, 03:27 PM - Forum: Bug Reports - Replies (3)

Hi,

I'm trying to dim an array at a specific address which has been defined as a constant of type uinteger, unless I add 0 to the constant the code does not compile. 

const tileStart as uinteger = $4000+384

dim tile(0 to 255) as uinteger at tileStart         'this fails to compile with "Address must be a numeric constant expression" 
'dim tile(0 to 255) as uinteger at tileStart+0         compiles OK

print at 0,0;str(tileStart)

Am I missing something?

This is version: [v1.14.0]

Print this item