Page 1 of 1

reading integer give a random number

Posted: Sat Apr 29, 2023 9:59 pm
by bfernhout
i use this code:

Code: Select all

Procedure SRivPlop()
  
  Protected X.i,
  Dim SRivMatrix.i(5)
  Restore SRiv
  
  For X = 0 To 5
    Read.i SRivMatrix(x)
  Next
  
  CallDebugger
  
  Sriv:
  DataSection
    Data.i 0, 0, 3, 3, 0, 0 
  EndDataSection
  
EndProcedure

SRivPlop()
This code gives no errors but when the data is readed, the numbers in the array makes no sence.
the number displayed are :

Code: Select all

-1729382256562026680
5818704903870087214
5846490494384949328
5212952597069561856
2948876202223619211
-4286503255484888088
This is not the numers i did write down in de data.
What is wrong here. Or do i have a bug found?

Re: reading integer give a random number

Posted: Sat Apr 29, 2023 10:05 pm
by bfernhout
Forgot to mentiom that i am running on a AMD 64 bit system 3.8 Ghz windows 11 Pro
AMD Ryzen 7 5800X 8 core
Nvidea GF RTX 3060 TI 8 GB
Memory 32 GB

This information may help

Re: reading integer give a random number

Posted: Sat Apr 29, 2023 10:45 pm
by Starwolf20
Works if you write the DataSection like that...

DataSection
Sriv:
Data.i 0, 0, 3, 3, 0, 0
EndDataSection

Re: reading integer give a random number

Posted: Sun Apr 30, 2023 2:58 am
by Demivec
To add a little bit more to what Starwolf20 wrote, if the label is not in the DataSection it will instead reference the point in memory where the code is, not the data.

All data in all the DataSections throughout the program are combined together and stored separately from the code. So if the label isn't in the datasection itself it will only work if you are very lucky.

Re: reading integer give a random number

Posted: Sun Apr 30, 2023 3:05 am
by BarryG
Not a bug. The manual says labels used with "Restore" must go inside the DataSection/EndDataSection, and yours is outside it.

Re: reading integer give a random number

Posted: Mon May 01, 2023 8:44 pm
by bfernhout
Thanks for the information. I did not notice it by miself that i did write it wrong.