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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 262
» Latest member: AnthonyGaxia
» Forum threads: 1,075
» Forum posts: 6,440

Full Statistics

Online Users
There are currently 154 online users.
» 0 Member(s) | 153 Guest(s)
Bing

Latest Threads
Красивые букетики
Forum: News
Last Post: AnthonyGaxia
4 hours ago
» Replies: 0
» Views: 6
Printing with FZX
Forum: Help & Support
Last Post: boriel
07-17-2025, 09:08 PM
» Replies: 1
» Views: 358
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 2,530
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 2,711
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 2,263
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 5,266
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 3,696
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 3,434
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 1,951
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 4,737

 
  About POS
Posted by: programandala.net - 04-18-2010, 08:25 PM - Forum: ZX Basic Compiler - Replies (5)

I just needed the POS function to adapt a code of mine from FreeBASIC... But I didn't suspect POS is already defined in ZX Basic! I realized when the compiler halted: it seems two POS functions are too much Smile

By the way, this was my definition:

Code:
#define systemSPOSN 23688

function pos() as ubyte

    return 34-peek(systemSPOSN)

end function

First I made some tests, because I wasn't sure if the object code produced by the compiler uses the ROM routines and so the related system variables are updated as well. I find out the content of the S POSN system variable is not the same when the same code is executed by Sinclair Basic or compiled by ZX Basic:

Code:
#define systemSPOSN 23688

cls
print at 0,0;peek(systemSPOSN) ' prints 34
print at 1,10;peek(systemSPOSN) ' prints 24
print at 2,20;peek(systemSPOSN) ' prints 14
print at 3,25;peek(systemSPOSN) ' prints 9
stop

' Sinclair Basic prints one less (33, 23, 13 and 8)!

Yes, the same program in Sinclair Basic returns lower values. It's interesting.

Anyway, it's great POS already exists. I took a look at its source file and the rest of library files. There are many interesting undocumented functions.

I created the POS page in the wiki.

Print this item

  conflict between "label EQU" and "#DEFINE label"?
Posted by: programandala.net - 04-18-2010, 06:51 PM - Forum: Bug Reports - Replies (1)

I got the following error:

Quote:random.asm:10: Error: Syntax error. Unexpected token '23672' [INTEGER]

I took a look at the random.asm library. Lines 10 are 11 are the following:

Code:
    LOCAL TAKE_FRAMES
    LOCAL FRAMES

And line 31:

Code:
FRAMES EQU    23672

So I suspected the problem had something to do with this line of my program:

Code:
#define FRAMES 23672

I defined FRAMES because I use it for several calculations.

I was right: I renamed it MYFRAMES and the error didn't happen again.

Does it means the EQU assembler labels conflict with #DEFINEd labels?

Print this item

  AttributeError: 'SymbolSTRSLICE' object has... (*solved*)
Posted by: programandala.net - 04-18-2010, 02:49 PM - Forum: Bug Reports - Replies (6)

For the second time, I get the following output (version 1.2.5):

Quote:marcos$ zxb.py --tap --autorun --BASIC --sinclair colegio_erevest_4.bas
Generating LALR tables
Generating LALR tables
WARNING: Token 'UMINUS' defined, but not used
WARNING: There is 1 unused token
Traceback (most recent call last):
File "/home/marcos/bin/zxb.py", line 255, in <module>
sys.exit(main(sys.argv)) # Exit
File "/home/marcos/bin/zxb.py", line 203, in main
zxbtrad.traverse(zxbtrad.FUNCTIONS) # This will fill MEMORY with pending functions
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 250, in traverse
traverse(l)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 959, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 257, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 770, in traverse
traverse(tree.next[1])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 720, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1004, in traverse
traverse(tree.next[i])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1008, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 569, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 375, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 530, in traverse
if tree.next[0].token != 'STRING' and tree.next[0].token != 'ID' and tree.next[0].symbol._mangled[0] != '_':
AttributeError: 'SymbolSTRSLICE' object has no attribute '_mangled'

I've searched for "mangled" in the forums, but there's no message about it.

It seems it happens when no more syntax errors are found in the source, but I'm not sure. Any clue? Is it a compiler issue or is it caused by my program?

Print this item

  concatenation of a str and a str function result (*solved*)
Posted by: programandala.net - 04-17-2010, 07:45 PM - Forum: Bug Reports - Replies (13)

I cannot understand the reason of some errors I'm getting about converting a string into a value and a value into a string.

In order to debug, I wrote a simplified version of the code:

Code:
dim a as ubyte

let a = 10
print "Yes: "+stringIF(a,"yes")+"..." ' ERROR: Cannot convert string to a value. Use VAL() function
print "Nothing: "+stringIF(0,"yes")+"..."
stop

function stringIf(condition as uinteger,text as string) as string

    if condition then
        return text
    else
        return ""
    end if

end function

stringIf is a simple alternative to the Sinclair Basic use of AND with strings:

Code:
LET A$ = "string" AND condition

So I can port it this way:

Code:
let aString = stringIf(condition,"string")

I don't understand why the following line fails:

Code:
print "Yes: "+stringIF(a,"yes")+"..." ' ERROR: Cannot convert string to a value. Use VAL() function

I tried an alternative, but nothing changed:

Code:
dim a as ubyte
dim t as string

let a = 10
let t = "Yes: "+stringIF(a,"yes")+"..." ' ERROR: Cannot convert string to a value. Use VAL() function
let t = "Nothing: "+stringIF(0,"yes")+"..."
stop

Beside those simple tests, I did several tries in the original code, and noted "FINE" or "ERROR" (all variables are DIMed as ubyte):

Code:
    #define true 1

    tell("Son las "+str(currentHour)+stringIf(currentMinute<>0,":"+stringIf(currentMinute<10,"0")+str(currentMinute))+" de la noche.") ' ERROR : Cannot convert string to a value. Use VAL() function
    print "Son las "+str(currentHour)+stringIf(currentMinute<>0,":"+stringIf(currentMinute<10,"0")+str(currentMinute))+" de la noche.") ' ERROR : Cannot convert string to a value. Use VAL() function
    print "Son las "+str(currentHour) ' FINE
    print "Son las "+str(currentHour)+str(currentMinute)+" de la noche." ' FINE
    print "Son las "+stringIf(currentMinute<>0,":") ' ERROR: Cannot convert string to a value. Use VAL() function
    print "Son las "+stringIf(true,":") ' ERROR: Cannot convert string to a value. Use VAL() function
    print stringIf(true,":") ' FINE

One of the tries caused both errors at the same time (string into value and vice versa!):

Code:
    #define true 1
    dim temp as string
    ' the following line gets two errors:
    ' Cannot convert value to string. Use STR() function
    ' Cannot convert string to a value. Use VAL() function
    let temp = "Son las "+stringIf(true,":")
    print temp

The stringIf function is defined to return a string, so I cannot understand what's the problem.

I tried another thing... Maybe it has to do with concatenation... Let's see:

Code:
print "Yes: ";stringIf(a,"yes");"..." ' FINE

it compiles! So the problem has something to do with string concatenation.

I'm stuck. I need some enlightenment.

Print this item

  A help forum
Posted by: programandala.net - 04-17-2010, 07:16 PM - Forum: Wishlist - Replies (2)

Boriel,
I miss a fourth forum for asking for help. I'm working on my second port from Sinclair Basic to ZX Basic, and sometimes I need some help about some issue that it's not in the docs, and I cannot find it in the sources. Meanwhile, I'll keep on using the bugs forum.
What do you think?

Print this item

  error line numbers affected by #if(n)def
Posted by: programandala.net - 04-16-2010, 07:21 PM - Forum: Bug Reports - No Replies

I realized the line numbers shown in the error reports don't include the lines discarded by #ifdef and #ifndef. I mean, the lines of the source discarded by #ifdef and #ifndef are not counted.
I guess the compiler discards those parts before doing the next pass, but the annoyng effect is the lines of errors and warnings are not real.
This is a problem, mainly with long programs where conditional compilation is used a lot.

Print this item

  const as string?
Posted by: programandala.net - 04-16-2010, 06:29 PM - Forum: Bug Reports - Replies (6)

I got the following error with both 1.2.5 and 1.2.6:

"Initializer expression is not constant"

The line is:

const prompt as string = chr(18,1,62,18,0,8)

I supossed the reason is the chr() calculation, so I put a literal string instead:

const prompt as string = "my prompt"

but nothing changed, the error remains.

The wiki page on CONST is not written, so I searched for CONST in the sources for examples. I searched all the sources for a "const as string" example (using a regular expression), but found nothing.

Are constant strings forbidden?

Print this item

  String Issues
Posted by: britlion - 04-16-2010, 05:15 AM - Forum: Bug Reports - Replies (3)

I'm having a weird issue. I have the following code setting a string:

Code:
IF currentMatchType=FACUP then let faCupMatchCountString="Round "+STR$(faCupMatchCount)
   IF faCupMatchCount=7 Then let faCupMatchCountString="Semi-Final"
   ELSEIF faCupMatchCount=8 Then let faCupMatchCountString="Final"
   END IF

Later on it prints that string. On a 1-6 it prints "Round 1" / "Round 2" and so on. As soon as the FaCupMatchCount hits 7 it prints gibberish and/or crashes...


Is there a potential issue in the string handling, or have I written more notoriously bad code?

The thing is, it works for the earlier numbers...
(yes, I can provide the whole program again if you wish... It's sometimes difficult to tell if I've done something amiss, or the compiler has - we've had array bounds checking issues already!)

If I change the code so both Ifs say "8" then it prints "Round 7" as expected, and then prints gibberish instead of "Final"

Here's the code that actually prints it at the point that it fails:
Code:
if currentMatchType=FACUP then print "F.A.Cup Match - ";faCupMatchCountString
    else PRINT "League Match - ";
       IF division=4 then print "League 2"
          elseif division=3 then print "League 1"
          elseif division=2 then print "Championship"
          else print "Premier League"
       END IF
    END IF

It prints "F.A. Cup Match - " and then gibberish on the screen.

Print this item

  for-next repeats forever because of data type limit
Posted by: programandala.net - 04-09-2010, 01:15 AM - Forum: Bug Reports - Replies (4)

Hi all,

I'm working on my first port from Sinclair Basic to ZX Basic. I'm excited about it. I'd love to program compiled versions of some old programs of mine, but first I need to acquaint with this wonderful and impressive tool.

I'm using ZX Basic 1.2.0 under Debian GNU/Linux.

Well, I think I found a kind of bug. Here you are the test:

Code:
' The following loop works as expected:

dim b0 as ubyte

for b0=0 TO 254
    print at 0,0;"b0=";b0;"    "
next b0

' The following loop works as expected too:

dim b1 as uinteger

for b1=0 TO 255
    print at 1,0;"b1=";b1;"    "
next b1

' But the following loop starts again forever:

dim b2 as ubyte

for b2=0 TO 255
    print at 2,0;"b2=";b2;"    "
next b2

border 4
print "This message never will be printed"
pause 0

I found the problem because I needed a loop from 0 to 255, so I used the ubyte data type for the index variable. Then I realized the loop repeated forever!

I guess the reason is NEXT increases the loop index before cheking it, so 256 becomes 0 after storing it back into the ubyte variable and the check gets wrong: the loop starts again because the index is zero! I guess the same happens with other data types, as long as their limits are reached, but I didn't try.

Do you think this is a language feature or a compiler bug? Smile

I'm programming a project in FreeBASIC too, but I didn't try this. I'll try a similar code and I'll see what happens.

Print this item

  ZXBasic 1.2.6-r1542
Posted by: boriel - 04-05-2010, 11:07 PM - Forum: Bug Reports - Replies (5)

Okay. This release is already available for download, and fixes a -O3 bug (another one). The most common effect is some optimizations NOT being done.
Please, download and test: <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542.msi">http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542.msi</a><!-- m -->

Print this item