Author Topic: Routines  (Read 313143 times)

0 Members and 2 Guests are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #465 on: November 22, 2010, 02:36:58 pm »
Yeah we often think parhentesizes can be omitted because it works somewhere, but it's not intended to be like that. I personally close them whenever possible. In the end it saves me much trouble.

Glad it works now!

Offline Kiligolo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 218
  • Rating: +10/-1
    • View Profile
Re: Routines
« Reply #466 on: November 22, 2010, 02:40:20 pm »
But when the program is compiled, it's the same size even if we remove parhentesizes?
Spoiler For Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler For Some screen shots:
       
The screenshots are in french but there is an english version

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: Routines
« Reply #467 on: November 22, 2010, 02:54:12 pm »
But when the program is compiled, it's the same size even if we remove parhentesizes?

Sure, I think.
Only interpreted langage have difference size with less parenthesized.
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #468 on: November 22, 2010, 03:23:11 pm »
It should be. Parenthesizes should only be closed if you're in extreme need of every byte of RAM available.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Routines
« Reply #469 on: November 22, 2010, 05:49:13 pm »
I believe you mean,
It should be. Parenthesizes should only be left open if you're in extreme need of every byte of RAM available.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #470 on: November 23, 2010, 12:06:34 am »
Er yea X.x

I got it the other way around. My bad x.x

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #471 on: November 27, 2010, 09:59:16 pm »
flexible-ish dropdown menu.
inputs - sub(MEN,Ypos*256+Xpos,numItems,"String1","String2","String3","String4") // String2-4 are optional. 0 < numItems < 5
String format:
cannot be more than 10 characters (bummer).
must be formatted like so: "4File". the 4 is the length of the string.
if you have a string greater than 9 in length, check this table to find out what you should put before the string. for example, ":Horizontal" will work.
outputs - integer 0-(numItems-1) indicating which option was selected

Code: [Select]
Lbl MEN
r1^256->X
r1/256->Y
0->Z
For(U,1,r2
Text(X+2,U-1*7+Y+1,{U*2+°r2}^r->V+1
!If Z:V->Z:End
If {V}>{Z}
V->Z:End
End
{Z}-48->{Z}
ZAsm(EFB44C6F2600)->V  //finds the length of a string in pixels. thank you calc84maniac!
{Z}+48->{Z}
RectI(X,Y,V+3,r2*7+2
RectI(X+1,Y+1,V+1,r2*7
0->Z
Repeat getKey(9) or getKey(54)
getKey->K
=1-(K=4)+Z->Z
!If +1:r2-1->Z
End
Z^r2->Z
End
Z*7+Y*256+X+V+3->r1:Z
Return

just so you know, this routine *can* fail. Quit and Save have different pixel-lengths on calculator but they'd both be represented as 4Quit and 4Save in my routine.since Save is larger than Quit, make sure you put 4Save as an argument before 4Quit in the parameter list.

also, if you want to use more than 4 options you can group them into categories and call the routine more than once. the next logical placement for a menu after selection is stored into r1 for convenience.
« Last Edit: November 28, 2010, 04:44:52 pm by nemo »


Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Routines
« Reply #472 on: November 28, 2010, 08:13:41 pm »
A while back, I wrote a sort of character explorer" for selecting a number and it displays the ►Char thing.  now, I've optimized it a bit and added the ►Tok tokens.
[←]/[→] : +/- 1
[↑]/[↓] : +/- 20
[+]/[-] : +/- 100
[*]/[/] : +/- 1000
[CLEAR] : quit and save number into Ans

This supports two-byte tokens.
It stores the number last selected into Ans.

(it's not really a routine, but I couldn't think of a better place to post it)

*****EDIT*****
TOKENSRC is empty.  Thank you old wabbitemu error.
Correct 8xp is ASCIISRC.
« Last Edit: February 19, 2011, 04:25:18 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #473 on: November 28, 2010, 11:07:09 pm »
Creating Ans as a string:
Code: [Select]
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
GetCalc(Str0AN,size_goes_here)
« Last Edit: November 29, 2010, 12:08:47 am by Runer112 »

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Routines
« Reply #474 on: November 29, 2010, 12:02:44 am »
Code: (Creating Ans as a string) [Select]
Data(4,ᵀAns,0,0)→Str0AN
DelVar Str0AN
GetCalc(Str0AN,size_goes_here)
What does that do? Does it store the token/character to Ans?
Vy'o'us pleorsdti thl'e gjaemue

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Routines
« Reply #475 on: November 29, 2010, 12:07:20 am »
It creates a string which is the Ans variable. You have to call Delvar manually, because for some reason Getcalc() wasn't deleting it if Ans wasn't already a string.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Routines
« Reply #476 on: November 29, 2010, 12:08:49 am »
What does it store in the Ans string, though?  The token or the character?
Vy'o'us pleorsdti thl'e gjaemue

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Routines
« Reply #477 on: November 29, 2010, 12:10:24 am »
It doesn't store anything, it just creates the string.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Routines
« Reply #478 on: November 29, 2010, 12:24:15 am »
Oh, so one could choose what to store in Ans...I guess I'll put that in ;)

How do I get the size required by getcalc( ?
Looking at some of the two-byte tokens...huge...
« Last Edit: November 29, 2010, 12:27:20 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Routines
« Reply #479 on: November 29, 2010, 12:31:13 am »
Well, it's a string of tokens, so you'll just have to manually count tokens :-\