Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Hello Cemetech Users! I have a little problem. I'm just playing a bit with Appvars in ICE and so far everything has worked out. But if I wanted to read from one, my calculator reset itself.

How I wrote something in the appvar:

Code:
:46→NUMBER
:sum(0)
:sum(1,"TEST","w+")→SLOT
:sum(4,NUMBER,1,1,SLOT)


And how I wanted to read something:

Code:
:sum(0
:sum(1,"TEST","r")→SLOT
:sum(5,NUMPTR,1,1,SLOT)
:Disp NUMPTR

What am I doing wrong?

Then I have one more question. Is it possible to store several objects in ICE (like strings or lists) in an appvar or is this not possible? I don't quite get Appvars that way.
Yan-Nick wrote:
Hello Cemetech Users! I have a little problem. I'm just playing a bit with Appvars in ICE and so far everything has worked out. But if I wanted to read from one, my calculator reset itself.

How I wrote something in the appvar:

Code:
:46→NUMBER
:sum(0)
:sum(1,"TEST","w+")→SLOT
:sum(4,NUMBER,1,1,SLOT)


And how I wanted to read something:

Code:
:sum(0
:sum(1,"TEST","r")→SLOT
:sum(5,NUMPTR,1,1,SLOT)
:Disp NUMPTR

What am I doing wrong?

Then I have one more question. Is it possible to store several objects in ICE (like strings or lists) in an appvar or is this not possible? I don't quite get Appvars that way.


You need to close the file slot.
Sum(3, slot
you need to do sum(0) at the end of your program as well.

Also, if you are writing a number to the file, you will need the degree sign ° before the variable. This is only possible If you are using a variable. Without that symbol, ICE will use the number as an address, accessing at the number, rather than the number itself.
Where exactly should I use the degree sign °? I tried this, but it only came out 0:

Code:
:46→NUMBER
:sum(0)
:sum(1,"TEST","w+")→SLOT
:sum(4,NUMBER,1,1,°SLOT)


Then I wanted to read it

Code:
:sum(0)
:sum(1,"TEST","r")→SLOT
:sum(5,PTRNUM,1,1,°SLOT)
:Disp PTRNUM

The calculator showed me 0.

If you had time, could you show me an example code?

EDIT:I know what I did wrong. I should not have placed the degree sign before SLOT, but before the variable where I stored the number I wanted to store in the appvar, or before the variable where I wanted to store the number from the appvar. Thanks beckadamtheinventor and commandz for your help Very Happy
I used to have a lot of issues with this too.

To write:

Code:

CloseAll()
Open(“appvar”,”w+”)->A
Write(^^oVARIABLE,3,1,A)


To read:

Code:

CloseAll()
Alloc(3->VARIABLE
Open(“appvar”,”r”)->A
Read(VARIABLE,3,1,A
***{VARIABLE}->VARIABLE


Does this help?
epsilon5 wrote:
I used to have a lot of issues with this too.

To write:

Code:

CloseAll()
Open(“appvar”,”w+”)->A
Write(^^oVARIABLE,3,1,A)


To read:

Code:

CloseAll()
Alloc(3->VARIABLE
Open(“appvar”,”r”)->A
Read(VARIABLE,3,1,A
***{VARIABLE}->VARIABLE


Does this help?


Don't use three asterisks.
No asterisks means the same thing.
Wink
Also the degree operator works with both reading and writing work a variable.
I don't have big problems with variables anymore, but can I store lists in an appvar and if so, how?

How I want to save the list in the appvar:

Code:
:2→*{L₁+0}
:20→*{L₁+1}
:sum(0)
:sum(1,"TEST","w+")→SLOT
:sum(4,°L₁,2,1,SLOT)

How I want to read the list in the appvar:

Code:
:sum(0)
:sum(1,"TEST","r")→SLOT
:sum(5,°L₂,2,1,SLOT)
:*{L₂+0}→NUMZERO
:*{L₂+0}→NUMONE

Would that work?
Lists are already pointers, so you don't use the degree sign with them. The degree sign gets a pointer to a variable's location in memory. L1 is a pointer to an area of memory that can be used for anything. The Read and Write commands read and write into the area of memory pointed to by the pointer, which in the case of °VAR is VAR and in the case of L1 is the beginning of L1.
It worked, thank you very much for your help commandblockguy. Very Happy
  
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 GMT - 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