Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Since I'm tired of making new forum posts for ICE, this is where all if it will be from now on. When answering my posts please begin your post with the topic number (e.g. T1), as sometimes I will post multiple questions at the same time)

T1. Storing Variables in ICE

I've been using ICE for just about all my programming lately, learning all I can from PT_'s documentation. I've had a hard time trying to figure out how to store lists into the calculator. I don't mean something like "CopyData(L1,3,1,2,3,4,5)", because L1 will not be "{1,2,3,4,5}" if you were to recall L1 from the homescreen. I'm pretty sure I have to store my list in an appvar, but I don't know how to.
For Example: I am making a baseball game. One of the most obvious things I need is a save option. If i want to save balls, strikes, and outs respectively into the appvar "BBALLSAV", how would I do that, and how would I recall them. I know I have to use "BBALLSAV"s memory address (I think), and I need to use "sum()" functions, but beyond that, my knowledge stands on "thin ICE"


T2. Using det(90) - Rotating Sprites

I thought initially that using det(90) would be fairly simple to me, but as it turns out, it hasn't been. For some reason, ICE refuses to rotate my sprite (my sprite is a square 12x12). I pretty sure I followed the correct syntax as stated in PT_'s documentation, but I must have not. Please give me an example on how to rotate a sprite.
TI84pceBasicPro wrote:
Since I'm tired of making new forum posts for ICE, this is where all if it will be from now on. When answering my posts please begin your post with the topic number (e.g. T1), as sometimes I will post multiple questions at the same time)

T1. Storing Variables in ICE

I've been using ICE for just about all my programming lately, learning all I can from PT_'s documentation. I've had a hard time trying to figure out how to store lists into the calculator. I don't mean something like "CopyData(L1,3,1,2,3,4,5)", because L1 will not be "{1,2,3,4,5}" if you were to recall L1 from the homescreen. I'm pretty sure I have to store my list in an appvar, but I don't know how to.
For Example: I am making a baseball game. One of the most obvious things I need is a save option. If i want to save balls, strikes, and outs respectively into the appvar "BBALLSAV", how would I do that, and how would I recall them. I know I have to use "BBALLSAV"s memory address (I think), and I need to use "sum()" functions, but beyond that, my knowledge stands on "thin ICE"


Okay. So, here we go.

T1.
You might have to use a Basic subprogram to use/load saves. A lot of ICE programs do this. However, there is another option. You can create an appvar, write data to it, and read data from it. More information on this is in the documentation. Also check out the command list, because that also helps a lot. (I don't know if it's updated, but it probably is)
T1. Thank you, except for the fact that you didn't explain how to use an appvar. Also if you store "5->A" into your ICE program, I thought you couldn't access elsewhere.
TI84pceBasicPro wrote:
T1. Thank you, except for the fact that you didn't explain how to use an appvar. Also if you store "5->A" into your ICE program, I thought you couldn't access elsewhere.


You can't. ICE variables are different from Basic variables. Look in the command list included in the ICE download, and look to the section that uses "sum("s. Look through, and there will be information telling you how to read/write to an appvar, create files, and stuff like that. It also shows the different modes to use when editing. You can look at SM84CE's Diwali program for an example. IIRC, it uses appvars to save/load data. It was his CC21 entry. He also asked about appvars in his ICE thread, so you can look that up as well.

Command list here. (Thank Mateo for the link)

EDIT: some example code for making an appvar:

Code:

...random stuff here
sum(1,"TEST","w+")

This creates an appvar "TEST" that can be written to, and read from.

Go here for all the commands and modes. (Link again provided by Mateo)

If you want to write stuff that can be accessed through the homescreen, use sum(2. Change the type to 0, for access to vars A to theta.

"sum(2,"NAME","MODE",TYPE)

OpenVar Opens a variable with name "NAME" and type TYPE. See sum(1 for the "MODE" options. Returns the slot number or 0 if failure. TYPE options:
- 0 - Real
- 1 - Real list
- 2 - Matrix
- 3 - Equation
- 4 - String
- 5 - Program
- 6 - Protected program
- 12 - Complex
- 13 - Complex list
- 21 - Appvar
- 22 - Temp program"

Copied from the command list. Please read it. It is helpful. You can create all of those with sum(2. OR, just learn C, and you have access to even more. (Maybe, maybe not. Propaganda fed to me by THE C GUY)

EDIT: Can an admin move this topic to the AXE and ICE sub forum? I think it's more fit for that.
Yes, it does use AppVars to save and load, here is the link to my CC21 thread.
The link to download the actual program is also in the thread (first page, iirc).
Just a note, the program was compiled with an older version of ICE, so the Cesium icon may not work if you are using the latest version of ICE.

The save/load code is there, if you need a commented version, just PM me. I don't think the commented version was what was submitted to the Archives...

https://www.cemetech.net/forum/viewtopic.php?t=14525
Thank you SM84CE, you were very helpful. Smile
I'm starting the card game HEARTS on ICE. If you run my program, you can see for some reason DEAL gets stuck at 40. Obviously I need all 52 cards to be dealt out and none of them the same. I'm not sure what's wrong. You can find the code here.

P.S. How do I copy my code from SC3?
Ctrl + A
Ctrl + C
[code][/code]
Ctrl + V

Rolling Eyes
The code seems fine to me and should work properly. Does it happen everytime you run the program or does it stop at *random* numbers?
I fixed a couple of things and now DEAL gets stuck at 1!


Code:

[i]HEARTS
0->A->B->C->D
For(DEAL,1,52
   Lbl REDEAL
   Output(1,1,DEAL
   Output(1,3,"/50
   1+remainder(rand,13->NUM  //Number of card generated
   1+remainder(rand,4->P   //Player to send card to
   1+remainder(rand,4->SUIT   //Well, self-explanatory
   (SUIT-1)*13+NUM->CARD   // Formula to generate card; each card has its own different value

//These are to make sure that no one has more than 13 cards and the "A+1->A" prepares to add the whatever the card value was to the player 1 (L1) and to send it to a free space in the list.
   If P=1
      If A=13
         Goto REDEAL
      End
      A+1->A
   End
   If P=2
      If B=13
         Goto REDEAL
      End
      B+1->B
   End
   If P=3
      If C=13
         Goto REDEAL
      End
      C+1->C
   End
   If P=4
      If D=13
         Goto REDEAL
      End
      D+1->D
   End


       //These make sure that CARD hasn't already been dealt out. The " 3* " are used for 3 byte entries. I think that's how it works
   CARD->L5(3*(A+B+C+D)         
        For(CHECK,1,A+B+C+D
           If CARD=L5(3*CHECK
         Goto REDEAL
      End
   End

//These store CARD into the player's hand in the next available slot in the list
   If P=1
      CARD->L1(3*A
   End
   If P=2
      CARD->L2(3*B
   End
   If P=3
      CARD->L3(3*C
   End
   If P=4
      CARD->L4(3*D
   End
End
I figured it out. So by testing the vars: A,B,C,D, I found out that each person WAS getting 13 cards and DEAL was getting stuck because when a repeat card did come I sent it to Lbl REDEAL where it would skip the increment in DEAL because I sent the Goto command within the For() command.


Code:

[i]HEARTS
0->A->B->C->D-
Repeat A=13 and B=13 and C=13 and D=13
   Lbl REDEAL
   Output(2,10,A
   Output(3,10,B
   Output(4,10,C
   Output(5,10,D
   1+remainder(rand,13->NUM
   1+remainder(rand,4->P
   1+remainder(rand,4->SUIT
   (SUIT-1)*13+NUM->CARD
   If P=1
      If A=13
         Goto REDEAL
      End
      A+1->A
   End
   If P=2
      If B=13
         Goto REDEAL
      End
      B+1->B
   End
   If P=3
      If C=13
         Goto REDEAL
      End
      C+1->C
   End
   If P=4
      If D=13
         Goto REDEAL
      End
      D+1->D
   End
   If DEAL>1
      For(CHECK,1,A+B+C+D
         If CARD=L5(3*CHECK
            Goto REDEAL
         End
      End
   End
   CARD->{L5+3*(A+B+C+D
   If P=1
      CARD->{L1+3*A
   End
   If P=2
      CARD->{L2+3*B
   End
   If P=3
      CARD->{L3+3*C
   End
   If P=4
      CARD->{L4+3*D
   End
End
I'm having a problem with convpng. I am using GIMP to edit. When I export the image and send it through convpng, it comes out 32x16 pixels! I don't know why this is happening.


https://imgur.com/a/DJ6F74A
That is not a bug for convpng/ICE but more like GIMP, I guess. Also, that image is way too large. TI-84+ CE
I use good old MS Paint myself. You can't have graphics that HD in an ICE project. Images take up a lot of space on calculators. The CE's screen size is only 320x240 pixels. If you want a larger image displayed with less memory used, look into ICE's ScaledSprite function.
Thank you, but even though I just went back and changed the scale on GIMP (Image > Scale Image...) and set it to 129/100 px, convpng still set it to 512 bytes. And when I open it on CEmu (any calculator really...), what pops up is some weird array of colors (found here)
I looked at a lot of SM84CE's "stuff" on ICE appvars. It's helped a lot and I figured out how to store and recall multiple variables within the same program. My problem is, is I don't know how to close an appvar and then recall variables from it. Also, when I downloaded Diwali, to experiment around with appvars, if I did something before running Diwali (I simply did 3+4 on the home screen), Diwali crashed.
Here's my code for storing and recalling data:


Code:

//Storing
sum(0
sum(1,"APVTEST","w+->A
Data(3,2,4,6,8,1,3,5,7,9->DATA
sum(4,DATA,27,1,A

//Recalling
sum(0
sum(1,"APVTEST","r+->A
sum(5,DATA,27,1,A
Copy(L1,DATA,27



For some reason the "Recalling" part resets my calculator. I'm not exactly sure why. Is DATA supposed to be defined when I use the read syntax (sum(5))? If so, how am I supposed to define it if I'm recalling it from an appvar? If not, what am I doing wrong?
I am having trouble displaying the value of a variable. When I use the PintStringXY, ex. det(18, X, 10,10), it displays random pixels. Am I doing something wrong, or is there another command to display the value stored in a variable? Thanks for your help! Smile
Legoman314 wrote:
I am having trouble displaying the value of a variable. When I use the PintStringXY, ex. det(18, X, 10,10), it displays random pixels. Am I doing something wrong, or is there another command to display the value stored in a variable? Thanks for your help! Smile

Use PrintUInt( instead of PrintStringXY(. Hope this helps! Smile
I know that someone told me that you can't mesh variables from ICE and BASIC. Does that include Strings? I also know that in the On-Calc Sprite Editor, the program uses a BASIC sub-program and fed Str1 into it. I am not aware he used ICE to do that, but even that being said, is there some way I can communicate in ICE between an ICE program and a BASIC sub-program?
TI84pceBasicPro wrote:
I know that someone told me that you can't mesh variables from ICE and BASIC. Does that include Strings? I also know that in the On-Calc Sprite Editor, the program uses a BASIC sub-program and fed Str1 into it. I am not aware he used ICE to do that, but even that being said, is there some way I can communicate in ICE between an ICE program and a BASIC sub-program?

Yes, you can open/create/write/read real OS strings just like appvars. Use something like this:

Code:
Open('Str1',"r+",4)->SLOT

Note that you have to use ' and not " !
PT_ wrote:
TI84pceBasicPro wrote:
I know that someone told me that you can't mesh variables from ICE and BASIC. Does that include Strings? I also know that in the On-Calc Sprite Editor, the program uses a BASIC sub-program and fed Str1 into it. I am not aware he used ICE to do that, but even that being said, is there some way I can communicate in ICE between an ICE program and a BASIC sub-program?

Yes, you can open/create/write/read real OS strings just like appvars. Use something like this:

Code:
Open('Str1',"r+",4)->SLOT

Note that you have to use ' and not " !


Although the characters in the TI-OS strings is different than in ICE strings Wink
Tokens

P.S. PT_: I have had very little success with reading and writing to OS strings, maybe they have a header of sorts?
  
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 2
» 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