Code:
iTESTS
det(0)

Alloc(1)→A

1->LT→LS
225→*{A}

While not(getKey(15)
det(5,255) //fill screen white
det(19,0,0) //set text X, Y
det(17,sum(17,°A,°LT,°LS)) // print the character
Pause

End
det(1)


I don't know why this crashes. I should be clearer, code runs once but on the second iteration it fails. I have tried moving things in and out of the loop but it seems that the sum(17 command is not acting as I would expect.
Allocating more memory doesn't work. I have tried everything I can think of. I am working on this to read from a program.

In my actual program I iteratively use

Code:
sum(5,°G,1,1,SLOT) // reading 1 char
det(19,F*8,NLINE*10) // text X, Y
det(17,sum(17,°G,°LT,°LS))

This does not work either.
I do not know ice, but use a more specific title and search the forms and use google. Make sure to check the docs and look at other people's code.
As was brought up in chat, sum(17 is apparently GetTokenString. I'm familiar with the C version of this function, and note that since it takes a pointer to A (which itself is already a pointer), it's actually updating the value of A to point after the current token. If you don't want this behavior, you should initialize another variable with the value of A in the loop so A itself doesn't get destroyed.

Another thing to note, though, is that tokens can be larger than one byte. When reading from a file this way, it's possible that you end up with the first byte of a two-byte token, and this would cause weird behavior if the second byte isn't there. I'm not sure exactly what the best way to deal with this is, but if there's a way to call ti_GetDataPointer for files, you can use that to have GetTokenString iterate over the file data directly, and it should just work. (Usually, you also want to use the returned token length in LT to keep track of remaining bytes in the file.)
calc84maniac wrote:

I'm not sure exactly what the best way to deal with this is, but if there's a way to call ti_GetDataPointer for files, you can use that to have GetTokenString iterate over the file data directly, and it should just work. (Usually, you also want to use the returned token length in LT to keep track of remaining bytes in the file.)


Even doing this and directly reading the data does not fix the issue of a crash after one iteration. I think this is a fault with the ICE compiler rather than one with my code. This is the edited version of my real (non test) code.


Code:
sum(16,SLOT)→E //getSize
det(5,255) // fill screen white
0→F
0→NLINE
0→LT→LS
sum(18,SLOT)→PTR

While F+(NLINE*20)<E and NLINE<30
det(19,F*8,NLINE*10) // fancy text X, Y setter
det(17,sum(17,°PTR,°LT,°LS) // print( GetTokenString( of the pointer
Pause
0→LT→LS
(new line logic)
End



I am inclined to believe this is an ICE issue because there are two unresolved topics with the same issue.

(Two people with the same issue)
https://www.cemetech.net/forum/viewtopic.php?p=274406
https://www.cemetech.net/forum/viewtopic.php?t=18623
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement