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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 258
» Latest member: manuelzo75
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

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

Latest Threads
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 206
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 265
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,529
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 522
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 422
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 292
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,021
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,857
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 400
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,510

 
  Mixing variable types in a numerical calculation
Posted by: patters - 01-05-2021, 12:50 AM - Forum: Help & Support - Replies (18)

My program is calculating attribute memory addresses for screen characters. In the interests of only DIMing what I need, I store the screen coordinates as UBYTE since I only need numbers from 0-32 at most.

I have spent a long time to find that the compiler doesn't perform the maths properly when these UBYTE variables are used with larger numbers in a calculation - even though I'm never asking for that UBYTE variable to be made any larger. See this example:

Code:
DIM x,y AS UBYTE
DIM attrMem AS INTEGER
CLS
y=18
x=4
attrMem=22528+y*32+x
POKE attrMem,16 'red paper, black ink

The result should be a red square AT 18,4. However, it is printed in the wrong location on the screen unless I change variables x and y to type INTEGER. Why would this be, since I am not asking for y or x to be expanded beyond their existing values? Is this expected behaviour, or a bug? I haven't really programmed any languages which have needed me to be so specific about number types before, so apologies if this is a silly question.

Print this item

  Declaring the length of a string
Posted by: patters - 01-03-2021, 01:55 AM - Forum: Help & Support - Replies (2)

In Sinclair BASIC you can DIM the length of a string using
DIM a$(5)

If I try something similar in Boriel BASIC
DIM a$(5) AS STRING

the compiler seems to interpret this as an array declaration.

Sometimes it's useful to declare the largest expected length of a string if you want to build it up of component pieces. e.g. In Sinclair BASIC:

Code:
10 DIM a$="hello"
20 DIM b$(8)
30 LET b$=a$
40 LET b$(4 TO 8)="p me!"
50 PRINT b$

If I try to do this in Boriel BASIC I can't declare the length, nor does it expand when needed. I seem to have to do it in two steps, one for overwriting the parts of the existing string, and a separate step to glue an addition to the end of the string.
Code:
DIM a$, b$
a$="hello"
b$=a$
b$(3 TO 4)="p "
b$=b$+"me!"
PRINT b$

Is this expected? Or is there a better way of building b$ from a$ in this example in only one step?

Print this item

Bug PRINT bug using CHR$(22) for inline positioning (*solved*)
Posted by: patters - 12-30-2020, 01:09 AM - Forum: Bug Reports - Replies (13)

It seems as if the compiler gets this wrong when the x coord is greater than 27. See example:

Code:
DIM a$, b$ AS String
CLS
a$=CHR(22,17,27,65,66) 'PRINT AT 17,27;"AB" - fine
b$=CHR(22,18,28,67,68) 'PRINT AT 18,28;"CD" - wrong location (19,0)
c$=CHR(22,19,29,69,70) 'PRINT AT 19,29;"EF" - wrong location (20,0)
PRINT a$;b$;c$
PRINT AT 20,28;"GH"                        '- fine
PRINT AT 18,0;"--"                         '- fine

At x=28 there is adequate space to print the two characters "CD" before the line wrap,  but strangely they end up being PRINTed AT 19,0 instead of AT 18,28. I presume it's because the compiler is forgetting that CHR$(22) and the following two special characters do not count towards the PRINTed length of the string. Will this error also occur for the other inline control codes for INK, PAPER, BRIGHT, OVER, etc.?

This error is present in the the latest stable release 1.13.2, and the betas for 1.14 (which I gather had some PRINT changes). Being able to set the coordinates and attributes inline like this is useful for manipulating pre-formed sprites.

Print this item

Bug Function to edit a string (*solved*)
Posted by: patters - 12-29-2020, 05:13 PM - Forum: Bug Reports - Replies (8)

I'm having trouble passing a string to a Function in order to edit it. The code which works fine outside of a Function just won't modify the string inside the Function for some reason. Any idea what I'm doing wrong?

Code:
DIM a$ AS String

FUNCTION editStringFN(stringToEdit$ AS String, position AS Integer, newLetter$ AS String) AS String
    stringToEdit$(position)=newLetter$
    RETURN stringToEdit$
END FUNCTION

CLS
a$="sample"
PRINT a$; "- original string"

'try to edit string via the function
a$=editStringFN(a$, 1, "i")
PRINT a$; "- function fails to edit"

'same edit without using the function
a$(1)="i"
PRINT a$; "- works as regular code"

Print this item

Bug PAUSE not working (*solved*)
Posted by: patters - 12-29-2020, 03:56 AM - Forum: Bug Reports - Replies (15)

In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.

Print this item

  Can't compile FSin trig function
Posted by: patters - 12-28-2020, 01:43 AM - Forum: Help & Support - Replies (6)

I'm new to the compiler, using it on Mac OS. Compiling a simple test program works fine. If I paste in the code from the FSin function from the documentation it won't compile:

Code:
../sine.bas:16: error: Syntax Error. Unexpected token 'ELSE' <ELSE>
../sine.bas:17: error: Syntax Error. Unexpected token 'IF' <IF>
../sine.bas:44: error: Syntax Error. Unexpected token 'FUNCTION' <FUNCTION>

I can't understand why the compiler doesn't like this, it looks ok to me. However, I can see an IF without an END IF. This is not how this listing is expressed in the forum post where it was first published. However, adding the missing END IF doesn't appear to help with the compiler errors. What is the problem here?

Print this item

  Bikers - ZX Spectrum Next
Posted by: CavernGames - 11-02-2020, 04:32 PM - Forum: Gallery - Replies (4)

Bikers - a brand new commercial game for the ZX Spectrum Next written using Boriel's ZX Basic Compiler and my own custom libraries for the ZX Spectrum Next.

https://cavern.games/bikers

  • 256 colour screen mode
  • Huge sprites
  • Tile mapped horizon graphics
  • Split tile map scrolling using copper
  • 30 fps at 60Hz
  • AY-3 music
  • 1MB or 2MB ZX Spectrum Next

[Image: bikers_screenshot3.png]

Print this item

  Code Size Limit
Posted by: yeti - 09-18-2020, 11:40 PM - Forum: ZX Basic Compiler - Replies (1)

Hello,

I wonder what the limit is to code size with Boriel on:

48K
128K
ZX Spectrum Next?

Can I write my program without thinking about how Boriel is paging memory in the background?

Print this item

  * Liquid War *
Posted by: .fito. - 09-15-2020, 08:12 PM - Forum: Gallery - Replies (1)

Hello friends, how are you?

I present you the game made by the FitoSoft team. Made in Basic and compiled with Boriel zxb. 



[Image: ldWO5v.png]

It is based on an old "Deep Scan" arcade machine. Your mission will be to use the miners of your destroyer to eliminate any underwater threat. You have more information and download at:

fitosoft.itch.io/liquid-war


regards

Print this item

  Spectrum BASIC Dialects
Posted by: Dorogusha - 08-31-2020, 04:22 PM - Forum: Wishlist - Replies (3)

Support for common dialects can be implemented.
In the librares (modules).

48 BASIC
128 BASIC (Where is PLAY & SPECTRUM ?)
+3 BASIC
TR-DOS

PRO-DOS
Laser BASIC
Mega BASIC
Beta BASIC
Softek IS
Softek FP


In many cases it is not necessary to follow a strict syntax such as "REM S, A, x, y" (from Softek IS)". And use more correct syntax. But the compiler must understand all synonyms and correct them by prompting the programmer. In turn, the programmer can choose any synonyms, including leaving it as it is.
It is not necessary to use the words LET and SUB in the program, but it is advisable when declaring ...
It is permissible to use signs that an object belongs to a particular type (using letters !,%, $ Or color), as well as an statement to a particular library (to understand where it came from).
The programmer can add his own new statements, functions, libraries, synonyms (i.e. own syntax). But all of them, of course, must be described by the programmer.

Print this item