Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
TI-BASIC
»
Is this possible?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Is this possible? (Read 3432 times)
0 Members and 1 Guest are viewing this topic.
Shazane Koronova
Guest
Is this possible?
«
on:
August 28, 2007, 10:06:00 am »
I would like a program to run a program based on the value of a variable... what I mean is I have something like
c1-->
CODE
ec1
If A=3
"S3
If A=4
"S4
Real(10,0,0
prgmXTEMP000
Real(10,1,0
c2
ec2
I want to do it without the if process because it gets long and wastes alot of code.
What I need is a way to turn a numeric variable into a string or else another way around this problem...
Logged
Radical Pi
LV9
Veteran (Next: 1337)
Posts: 1143
Rating: +5/-2
Is this possible?
«
Reply #1 on:
August 28, 2007, 10:11:00 am »
Yes, possible. I've wondered about doing the exact same thing.
Number to string:
c1-->
CODE
ec1{Ans,Ans→L2
{0,1→L1
LinReg(a+bx) Y1
Equ?String(Y1,Str1
sub(Str1,1,length(Str1)-3c2
ec2
Straight from Weregoose's routine page.
Logged
One of these days I'll get a sig I'm really proud of.
Netham45
LV11
Super Veteran (Next: 3000)
Posts: 2103
Rating: +213/-4
*explodes*
Is this possible?
«
Reply #2 on:
August 28, 2007, 10:12:00 am »
you can't avoid this, unless you like do this:
c1-->
CODE
ec1
while a=3
prgmFILE1
->a
end
while a=2
prgmFILE2
->a
end
c2
ec2
which is even uglier and more pointless.
Edit: Actually on second thought, I think there might be an ASM utility to do this, but it's impossible from pure BASIC.
Logged
Omnimaga Admin
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Is this possible?
«
Reply #3 on:
August 28, 2007, 10:15:00 am »
assuming you want to run a program based on a prefix then numbers, I generally do something like c1-->
CODE
ec1
"S"+sub("0123456789",A,1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
c2
ec2Thats what you want to do, right? Basically my version would be replacement for 10 if statements
If u want more than 10 programs:
c1
-->
CODE
ec1
"S"+sub("0123456789",int(.1A),1)+sub("0123456789",10fpart(.1A),1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
c2
ec2
basically if A=56 the program will check for prgmS56. However MAKE sure your program has two digits, else it may cause bad things to happen. Like don't do S1 instead of S10 for example
I hope this help out
Logged
Shazane Koronova
Guest
Is this possible?
«
Reply #4 on:
August 28, 2007, 10:48:00 am »
QuoteBegin-DJ Omnimaga+28 Aug, 2007, 16:15-->
QUOTE
(DJ Omnimaga @ 28 Aug, 2007, 16:15)
assuming you want to run a program based on a prefix then numbers, I generally do something like c1-->
CODE
ec1
"S"+sub("0123456789",A,1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
c2
ec2Thats what you want to do, right? Basically my version would be replacement for 10 if statements
If u want more than 10 programs:
c1
-->
CODE
ec1
"S"+sub("0123456789",int(.1A),1)+sub("0123456789",10fpart(.1A),1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
c2
ec2
basically if A=56 the program will check for prgmS56. However MAKE sure your program has two digits, else it may cause bad things to happen. Like don't do S1 instead of S10 for example
I hope this help out
I wrote it all out with Radical Pi's solution while you were writing this.... but this is definitely alot more efficient
However... what if I have single and double digits? S8, S9, S10, S11 and so on
Logged
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Is this possible?
«
Reply #5 on:
August 28, 2007, 10:59:00 am »
then you're stuck you need an if to do this:
c1-->
CODE
ec1
If A>9
Then
"S"+sub("0123456789",int(.1A),1)+sub("0123456789",10fpart(.1A),1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
Else
"S"+sub("0123456789",A,1
Real(10,0,0
prgmXTEMP000
Real(10,1,0
Endc2
ec2I didnt tested this one tho so you may need to check to make sure it works fine
Logged
Shazane Koronova
Guest
Is this possible?
«
Reply #6 on:
August 28, 2007, 11:52:00 am »
Well, the current code is more efficient than that... So Radical Pi's worked just fine.
Except for a phenomenon that cant possibly be caused by this new code...
I have an important variable Y that gets deleted for no reason.... that code doesn't even execute for it to happen but I haven't changed anything else at all. I couldnt even post the code until I can manage to isolate the problem, I cant tell where it happens...
Logged
Radical Pi
LV9
Veteran (Next: 1337)
Posts: 1143
Rating: +5/-2
Is this possible?
«
Reply #7 on:
August 28, 2007, 12:39:00 pm »
Do you do anything with the graphscreen? That could wipe the Y variable at times. It does for X I know...
Also, that wasn't my code. I even said it up there.
But, it works for single digit numbers, and all digit numbers (within reason), which was the point.
Logged
One of these days I'll get a sig I'm really proud of.
Shazane Koronova
Guest
Is this possible?
«
Reply #8 on:
August 28, 2007, 12:54:00 pm »
Oh yeah, I just meant the code you posted.
I constantly use the graph screen, and it has NEVER done this. Actually, I remember a long time ago I had this problem on someone's 83+...
any way you know of to make it not do this without changing the varialbe, because I'd have to change it in alot of places...
Logged
Radical Pi
LV9
Veteran (Next: 1337)
Posts: 1143
Rating: +5/-2
Is this possible?
«
Reply #9 on:
August 28, 2007, 01:15:00 pm »
I don't; can you post the full code?
Switching variables would probably be the best thing to do.
Logged
One of these days I'll get a sig I'm really proud of.
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Is this possible?
«
Reply #10 on:
August 28, 2007, 01:19:00 pm »
never ever use the y var in games, the graph screen operations keeps resetting it
Logged
Netham45
LV11
Super Veteran (Next: 3000)
Posts: 2103
Rating: +213/-4
*explodes*
Is this possible?
«
Reply #11 on:
August 28, 2007, 05:27:00 pm »
Don't use the 'X' var either.
Logged
Omnimaga Admin
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Is this possible?
«
Reply #12 on:
August 28, 2007, 05:49:00 pm »
i never got pb with X, but it is recommended that you dont use any vars used by graphs
Logged
Shazane Koronova
Guest
Is this possible?
«
Reply #13 on:
August 29, 2007, 04:01:00 am »
I solved it simply by doing something meaningless with Y after using the Y1 variable, because I figured out that it only erases Y the first time you use it afterwords and then it doesnt happen.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
TI-BASIC
»
Is this possible?