Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get a value after the call (*solved*)
#1
Is there any way that a program in ZX BASIC returns a value?

That I need is, once end my program this return a value to the +3 BASIC as in the following example:

Code:
10 LOAD "program.bin" CODE 32768
20 LET r =  USR 32768
30 PRINT r

Simply this Smile

Thank you.
[Image: FootSign.jpg]
Reply
#2
Sinclair Wrote:Is there any way that a program in ZX BASIC returns a value?

That I need is, once end my program this return a value to the +3 BASIC as in the following example:

Code:
10 LOAD "program.bin" CODE 32768
20 LET r =  USR 32768
30 PRINT r

Thank you.
This case is the same as in normal machine code. The value you can return is always a 16 bit integer stored in the BC register.
You can use END for that:

END 27613

Other than that, you must store the result in RAM and BASIC must PEEK from there.
Reply
#3
boriel Wrote:
Sinclair Wrote:Is there any way that a program in ZX BASIC returns a value?

That I need is, once end my program this return a value to the +3 BASIC as in the following example:

Code:
10 LOAD "program.bin" CODE 32768
20 LET r =  USR 32768
30 PRINT r

Thank you.
This case is the same as in normal machine code. The value you can return is always a 16 bit integer stored in the BC register.
You can use END for that:

END 27613

Other than that, you must store the result in RAM and BASIC must PEEK from there.

It doesn't work in a program compiled with some lines of code.

Code:
2 Variable not found, 30:  1

However, your simple example works :!:
[Image: FootSign.jpg]
Reply
#4
Sinclair Wrote:However, your simple example works :!:
This usually indicated some corruption in the BASIC system / stack. Check you're not overwriting the ERR_NR or any other system variables.
Reply
#5
boriel Wrote:
Sinclair Wrote:However, your simple example works :!:
This usually indicated some corruption in the BASIC system / stack. Check you're not overwriting the ERR_NR or any other system variables.

OK, thank you.

Tell me please, how I can do this check because the compiler not throws any error.
[Image: FootSign.jpg]
Reply
#6
And that the PAUSE freeze the flow of the program also has something to do or is another bug?
[Image: FootSign.jpg]
Reply
#7
Could be. PAUSE statement uses ROM PAUSE implementation which relays on interruptions.
This could also indicate a problem with interruptions (EI, DI), vector interruptions, etc.
I usually used EmuZWin with its integrated debugger to debug the asm code generated by the compiler, BTW.
Reply
#8
boriel Wrote:Could be. PAUSE statement uses ROM PAUSE implementation which relays on interruptions.
This could also indicate a problem with interruptions (EI, DI), vector interruptions, etc.
I usually used EmuZWin with its integrated debugger to debug the asm code generated by the compiler, BTW.

OK, I understand.

But going back to the previous question:

boriel Wrote:
Sinclair Wrote:Is there any way that a program in ZX BASIC returns a value?

That I need is, once end my program this return a value to the +3 BASIC as in the following example:

Code:
10 LOAD "program.bin" CODE 32768
20 LET r =  USR 32768
30 PRINT r

Thank you.
This case is the same as in normal machine code. The value you can return is always a 16 bit integer stored in the BC register.
You can use END for that:

END 27613

Other than that, you must store the result in RAM and BASIC must PEEK from there.

Which is the reason for which this program always returns on the r variable of the Sinclair BASIC the value 10027 and not the N value of the ZX BASIC?

Code:
dim N as uinteger = 12345
end N
[Image: FootSign.jpg]
Reply
#9
Sorry!
I completely overlooked this message!
Let me check it...
Reply
#10
Did you find a solution here?
Reply
#11
Not yet. But this is a BUG (I forgot about it, OMG).
Let me fix this...
Reply
#12
Okay, Fixed in version 1.8.6. Download from here:
<!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Archive#Latest_Development_Version">http://www.boriel.com/wiki/en/index.php ... nt_Version</a><!-- m -->

A pitty I forgot about this issue. Now I wonder is Sinclair is already interested... :?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)