This could be a useful resource for people looking to find useful/optimized ICE routines. This first post will be updated as routines are commented in for easy access.

Write & Read Number To / From Slot

Code:
Write(^^oNUM, 3, 1, SLOT
Read(^^oNUM, 3, 1, SLOT
Here are a few I like to use
Input Numbers in Fullscreen Mode

Code:
Data(1,3,6,9,0,0,0,0,0,2,5,8,0,0,0,0,0,1,4,7)->NUMBERS
While getkey(15)!=1
getkey->G
If G>=18 and G<=20 or G>=26 and G<=28 or G>=34 and G<=36
*{NUMBERS+G-18}->NUM
End
...
End


I will post more later, just have to go atm.
String Input routine
Inputs:
I : Input prompt
MAX : The maximum length of user input
BGC : Background color
TAC : Text color
TBC : Overtype/Cursor color
Outputs:
STR : user input string
Destroys:
K, X, Y, S, IX
Uses the text draw point for the position for display.

put these two lines near the beginning of your program
will fill from the draw point to (320,Y+9), where Y is the current Y draw position

Code:

"202377726D6820203D3D76716C6720203A7A75706B6663202079746F6A6562202078736E69646120202757524D4820203F2156514C4720203B5A55504B4643205F59544F4A4542202058534E49444120202B2D2A2F5E20203F333639292440202E32353828262020303134372C5D5B20203E203C7D7B20202020->SMAP
"aA1X->OVRTYPE

The actual routine (in SC3 ICE notation)

Code:

Lbl INPUT
GetTextX->X
GetTextY->Y
0->IX->S
Alloc(MAX+1->STR
SetTextTransparentColor(BGC
SetTextBGColor(BGC
SetColor(BGC
FillRectangle(X,Y,320-X,9
While 1
   SetTextFGColor(TAC
   SetTextXY(X,Y
   PrintString(I
   If *{STR
      PrintString(STR
   End
   SetTextFGColor(TBC
   PrintChar(*{OVRTYPE+S
   Call K
   S+(K=54 or K=48->S
   If S=3
      0->S
   End
   If K>9 and K<=47 and K!=15 and IX<MAX
      *{SMAP+40*S+K-9->*{STR+IX
      IX+1->IX
   End
   IX+(IX>~2->IX
   If K=56 and IX
      0->*{STR+IX
      IX-1->IX
   End
   If K=15
      0->*{STR
      SetTextFGColor(TAC
      Return
   End
   ReturnIf K=9 and *{STR
End

To use the routine:

Code:

Call INPUT

Make sure that BGC, TAC, and TBC are set before the routine is called (unless you replace them inside the actual routine), also that I is set to a string (the input prompt), and MAX is set to the longest string that you want the user to input.
This routine does all of its drawing from the current draw point to (320,Y+9) where Y is the current Y draw point.



Display hexadecimal (0 to 255):
Inputs: C - character to display
put this line near the beginning of your program:

Code:

'0123456789ABCDEF->HEX

the actual routine:

Code:

PrintChar(*{HEX+C/16
PrintChar(*{HEX+remainder(C,16




Number Input routine using arrow keys
Inputs:
I : Input prompt
N : minimum input value. Also the initial input value.
MAX : Maximum input value.
STEP: amount to go up/down for each arrow press.
Outputs:
N : Inputted value
Destroys:
K, X, Y
Uses the text draw point for the position for display.
will fill from the draw point to (320,Y+9), where Y is the current Y draw position.

Code:

Lbl NUMI
GetTextX->X
GetTextY->Y
N->MIN
Repeat K=9 or K=15
   FillRectangle(X,Y,320-X,9
   SetTextXY(X,Y
   PrintString(I
   PrintUInt(N
   Call K
   min(MAX,~STEP+max(MIN+STEP,STEP+N+STEP*((K=3)-(K=2->N
End
Return

This routine does all of its drawing from the current draw point to (320,Y+9) where Y is the current Y draw point.

Any of the variable names any of these routines can easily be modified (obviously), but make sure that you don't forget to not use any of the variables destroyed by the routine if you need them to retain their value before and after the routine.
  
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