﻿ Optimization Help
22 May, 2013, 09:41:41
 OmnomIRC You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

 Pages: [1]   Go Down
 Author Topic: Optimization Help -  (Read 1890 times) 0 Members and 1 Guest are viewing this topic.
trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « on: 02 February, 2009, 00:03:11 » 0

Well it's been a long time since I've programmed on the calc, so I'm a little rusty. I was just wondering if someone could help me optimize this code for speed:
 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 ClrHome"________->Str2   //8 Spaces in Str2"_ABCDEFGHIJKLMNOPQRSTUVWXYZ->Str1Ouput(1,1,"Whats your name?Output(3,1,"NAME: "+Str27->X8->dim(L1For(Y,1,81->L1(YEndRepeat K=105Output(2,X,"^   //up arrowOutput(4,X,"v   //down arrowgetKey->K//Moves arrows left or rightIf K=24 or K=26ThenOutput(2,X,"_    //_ = Blank SpaceOutput(4,X,"_    //_ = Blank SpaceX+(K=26)-(K=24Ans+8(Ans=6)-8(Ans=15->XEndIf K=25 or K=34ThenL1(X-6Ans+(K=25)-(K=34Ans+27(Ans=0)-27(Ans=28->ZIf X=7Thensub(Str1,Z,1)+sub(Str2,2,7EndIf X>7 and X<14Thensub(Str2,1,X-7)+sub(Str1,Z,1)+sub(Str2,X-5,14-XEndIf X=14Thensub(Str2,1,7)+sub(Str1,Z,1EndAns->Str2Z->L1(X-6Output(3,7,Str2EndEnd//Delete all variables

 « Last Edit: 02 February, 2009, 03:53:47 by trevmeister66 » Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
kalan_vod
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 15 July, 2011, 07:40:04
Date Registered: 01 September, 2008, 01:02:11
Posts: 2992

Total Post Ratings: +9

 « Reply #1 on: 02 February, 2009, 01:43:24 » 0

What does this program accomplish, I have better luck sometimes just re-writing it.
 Logged
trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « Reply #2 on: 02 February, 2009, 03:37:27 » 0

It lets the person create a 8-max letter name. They can move left or right and change the letter at that position. Every time you change a letter (by pressing up or down) it recreates the String (Str2) and displays it again. I know there's easier and faster ways to do it, but I also want it to look good instead of just entering it like normal.
 Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
{AP}

Offline

Gender:
Last Login: 19 May, 2013, 14:35:25
Date Registered: 16 October, 2008, 04:08:37
Location: TX
Posts: 987

Total Post Ratings: +65

 « Reply #3 on: 02 February, 2009, 03:48:29 » 0

Minor problem.
Look below... it shows it. (only hitting the arrows... the error happens on pressing up/down on the 2nd space)
This is just a direct copy of your code above.

I was testing it before I play with the optimizing... and that happened.
Can't find the issue... (maybe just too tired...)
 name.gif (16.45 KB, 96x64 - viewed 113 times.) Logged

trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « Reply #4 on: 02 February, 2009, 03:52:45 » 0

Heh I know why. In the code that say
 1 If X>8 and X<14
should be
 1 If X>7 and X<14

Heh I have it right in my program.
 Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Offline

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50214

Total Post Ratings: +2613

 « Reply #5 on: 02 February, 2009, 04:16:48 » 0

nice, kinda like Illusiat 12 naming routine (also used in Illusiat 2004)
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « Reply #6 on: 02 February, 2009, 04:18:19 » 0

nice, kinda like Illusiat 12 naming routine (also used in Illusiat 2004)
O snap. Do you think you have the code for that lying around anywhere? I'd like to take a look at it and see what differences we have and see what I can improve on.
 Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Offline

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50214

Total Post Ratings: +2613

 « Reply #7 on: 02 February, 2009, 04:23:03 » 0

Well, I doubt it is a good example. Back in the days (2002-2003) I was still using lbls/gotos inside loops, and some parhentesis were closed and " not omitted at the end of strings, just to give you an idea. If I have time to dig up the code I will post it though, but it's horrible. I would most likely do signifiantly better today.
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « Reply #8 on: 02 February, 2009, 04:25:32 » 0

Heh yeah I understand, but it never hurts to look at it even just to see how it works (even if it is unoptimized). but if you don't have it right now it's all good.
 Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
kalan_vod
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 15 July, 2011, 07:40:04
Date Registered: 01 September, 2008, 01:02:11
Posts: 2992

Total Post Ratings: +9

 « Reply #9 on: 02 February, 2009, 07:31:51 » 0

I made a small one, hope it works for what you want:

Quote from: BASIC Code
:ClrHome:1→A:"ABCDEFGHIJKLMNOPQRSTUVWXYZ →Str0:"-→Str1:8→dim(L1:Fill 1,L1
:Output(4,1,"NAME:
:Repeat θ=21
:L[size=0]1[/size](A→B
:Repeat θ=21 or θ=26 or θ=24
:A+6
:Output(3,Ans,"
:Output(5,Ans,"
:Output(4,Ans,sub(Str0,B,1
:getKey→θ
:B+(Ans=34)-(Ans=25
:Ans-27((Ans=28)-not(Ans→B
:End
:sub(Str0,Ans,1
:If θ=24:Then:"
:Output(4,A+6,Ans:End
:sub(Str1,1,A)+Ans→Str1
:inString(Str0,sub(Ans,A+1,1→L[size=0]1[/size](A
:A+6
:Output(3,Ans,"
:Output(5,Ans,"
:A+(θ=26 and A≠8)-(θ=24 and A≠1→A
:End
:sub(Str1,2,Ans→Str1
 Logged
trevmeister66
LV9 Veteran (Next: 1337)

Offline

Last Login: 12 January, 2011, 01:00:06
Date Registered: 30 October, 2008, 08:31:38
Posts: 1067

Topic starter
Total Post Ratings: +9

 « Reply #10 on: 02 February, 2009, 08:01:03 » 0

Thanks! That's a lot better.
 Logged

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Offline

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50214

Total Post Ratings: +2613

 « Reply #11 on: 02 February, 2009, 08:57:13 » 0

I assume these are the characters added in OS 1.15 or higher? This looks nice actually
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

kalan_vod
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 15 July, 2011, 07:40:04
Date Registered: 01 September, 2008, 01:02:11
Posts: 2992

Total Post Ratings: +9

 « Reply #12 on: 02 February, 2009, 09:13:44 » 0

I believe so kevin, you can get them in tifreaks font pack on ticalc. I actually now see a few optimizations in my own code..ew
 Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Offline

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50214

Total Post Ratings: +2613

 « Reply #13 on: 04 February, 2009, 08:14:05 » 0

moved to calculator help and support
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)