I am confused on how lists work in ICE. I read the documentation
In my code I have:
```
CopyData(L1,1,1,2,3) //I only need one byte
det(15,L1(0),1 //Displays 2560
```
For some reason, my lists contain wrong values.
I tried assigning them manually, using 1->L1(0)
It seemed to work, but when assigning the list's
elements to variables, they get wrong huge values.
I have ICE V2.2.1
You can store up to 2000 Bytes to a list like L1, L2... in ICE I think. When storing a value, you decide, how many bytes you need (one, two or three) to save it. One byte can hold values up to 255, two bytes up to 256*256 - 1 and three bytes up to 256*256*256 - 1

Here's an example

Code:
...
5→*{L1} // same as *{L1+0}
7→*{L1+1}
147→*{L1+2} // the * means that you want to use only one byte to save your value

2023→**{L1+3} // 2023 is higher than 255, so you need two bytes
638→**{L1+5} // make shure leave enough space to the previous value (3 and 4 are both already used by 2023)

365271→***{L1+7} // can also be written as →{L1+7}
15→*{L1+10}

// heres another example
For(A, 0, 10)
randInd(0, 2000)→{L1 + A*3} // index is multiplied by 3, because we use 3 byte values
End
...


You can also create "own lists" like this

Code:
...
Alloc(3000)→LIST // LIST can hold up to 3000 bytes

2763→{LIST}
387534→{LIST+3} // just use it like before

Copy(LIST, L1, 11) // copies the first 11 bytes from L1 to LIST, overwrites LIST 0-10
Copy(LIST+3, L1, 5) // copies the first 5 bytes from L1 to the 3rd to 7th byte of LIST




Alloc(30)→OTHERLIST
CopyData(OTHERLIST, 3, 17, 25, 7633) // copies 17, 25 and 7633 as 3 byte values into OTHERLIST, so you should use max 10 values here because OTHERLIST is 30 bytes long

// This can also be written like this
Data(3, 17, 25, 7633)→OTHERLIST // note: this wouldn't overwrite any data, you just create some new values in RAM and store their position (or pointer) into OTHERLIST
...


Hope this helps a bit. Have a nice day!
  
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