Forum
Error: LET string1 = string1 ( 1 TO LEN string1) (solved) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Error: LET string1 = string1 ( 1 TO LEN string1) (solved) (/showthread.php?tid=2558)



Error: LET string1 = string1 ( 1 TO LEN string1) (solved) - zarsoft - 08-14-2024

In my program I had

DIM EDLINE AS STRING ' global variable

and if I wrote

EDLINE = EDLINE( TO LEN EDLINE-2)

then the test

EDLINE = ""

it didn't always work

and I had to use

LEN EDLINE = 0


Then I changed it to

aux = EDLINE( TO LEN EDLINE-2)
EDLINE = aux

and the test

EDLINE = ""

worked well.


RE: Error: LET string1 = string1 ( 1 TO LEN string1) - boriel - 08-15-2024

Interesting... My guess is that if EDLINE is just 1 char, then LEN EDLINE - 2 is becoming 65535 (-1 as UInteger). 65535 which means However, after further investigation, this code (note, you can use [code] ... [/code] for code sections in the forum):

Code:
DIM EDLINE As String
LET EDLINE$ = "X"
X = EDLINE( TO LEN EDLINE -2)

PRINT "'";EDLINE;"' '";X;"'"
PRINT X = ""
PRINT LEN X = 0

This code should print
Code:
65535
'1' ''
1
1

it prints:
Code:
65535
'1' ''
0
1

instead. Will look into this, thanks!


RE: Error: LET string1 = string1 ( 1 TO LEN string1) - boriel - 08-15-2024

Okay, try this beta, and plz. let me know if it works ok: Shy
http://www.boriel.com/files/zxb/zxbasic-v1.17.3-beta15.tar.gz
http://www.boriel.com/files/zxb/zxbasic-v1.17.3-beta15.zip
http://www.boriel.com/files/zxb/zxbasic-v1.17.3-beta15-win32.zip
http://www.boriel.com/files/zxb/zxbasic-v1.17.3-beta15-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-v1.17.3-beta15-macos.tar.gz


RE: Error: LET string1 = string1 ( 1 TO LEN string1) - zarsoft - 08-15-2024

Works

Thanks