Author Topic: [SOLVED] SCI0 - Variables that aren't reset by Restore  (Read 11079 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Re: [RE-SOLVED] SCI0 - Variables that aren't reset by Restore
« Reply #30 on: July 08, 2022, 02:17:40 PM »
According to the docs, FGets takes 3 parameters:

http://scicompanion.com/Documentation/Kernels/FGets.html?highlight=fgets

And it returns the number of bytes read, not the string pointer.
Unless you're using some different kernel, or the docs are wrong, it doesn't look like this code works at all?
I run it a series of times:
Code: [Select]
(= fileHandle (FOpen "persist.tmp" 1))
(if (!= fileHandle -1)
(ReadTempFile 0)
(ReadTempFile 1)
(ReadTempFile 2)
(ReadTempFile 3)
(ReadTempFile 4)
(ReadTempFile 5)
(ReadTempFile 6)
(ReadTempFile 7)
)
(FClose fileHandle)
My understanding is that each call will return the next value down the line - which it does appear to do when working properly. Even when it's not "working properly" it still will make the value of the [gDeaths] variable arrays the corresponding numbers (it's just that the numbers are all wrong!)

Edit: from the attachment of the external file, it will set my arrays as follows: [gDeaths 0] = 2, [gDeaths 3] = 1, [gDeaths 6] = 1, and the rest will be 0.
« Last Edit: July 08, 2022, 03:17:38 PM by Doan Sephim »
Artificial Intelligence Competition

Offline Doan Sephim

Re: [SOLVED] SCI0 - Variables that aren't reset by Restore
« Reply #31 on: July 08, 2022, 02:30:03 PM »
So this is weird. I simply moved the gDeaths array to the top of the variable list and everything seems to be working properly.

But other things are all screwy now...So is there something wrong with how I have declared [str 10]?
« Last Edit: July 08, 2022, 02:31:58 PM by Doan Sephim »
Artificial Intelligence Competition

Offline troflip

Re: [SOLVED] SCI0 - Variables that aren't reset by Restore
« Reply #32 on: July 08, 2022, 02:36:50 PM »
Again, unless the documentation is wrong, FGets returns the number of bytes read, not the string pointer. So ReadNumber is reading from the wrong thing.

Ok, looks like the documentation might be wrong then... it returns the string pointer, so that part is fine.

Does the "sv plant" thing ring a bell? Are you using the str local variable anywhere else?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Doan Sephim

Re: [SOLVED] SCI0 - Variables that aren't reset by Restore
« Reply #33 on: July 08, 2022, 02:41:25 PM »
Again, unless the documentation is wrong, FGets returns the number of bytes read, not the string pointer. So ReadNumber is reading from the wrong thing.

Ok, looks like the documentation might be wrong then... it returns the string pointer, so that part is fine.

Does the "sv plant" thing ring a bell? Are you using the str local variable anywhere else?
The "sv plant" thing kinda went over my head. I thought I'd read a few times to see if I could make sense of it, but I haven't been able to do that quite yet.

Edit: Oh, maybe I do get it now. It'd be reading from the text resource perhaps.... makes me wonder if this isn't just an artifact of terrible naming conventions on my part...I'll have to work these out a little bit to see if I can't fix it, now that I see where the error is coming in.

I also use the str variable in another script where I display the number and kinds of deaths. Here's the procedure:
Code: [Select]
(procedure (deathCountIterator integer)
(Display
(Format @str 650 integer)
dsCOORD 20 textDown
dsFONT 4
)
(= textDown (+ textDown 9))
)

Yes, it looks like this code is actually writing the text resource onto the str...
« Last Edit: July 08, 2022, 02:50:16 PM by Doan Sephim »
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.022 seconds with 23 queries.