String to Variable

Code:

:FnOff
:DelVar Y0
:Input Str1
:String>Equ(Str1,Y0
:Y0->A
:Disp A

Note that if you type in something like 3+7 for String1 A is 10. Srry if that is added already.
Used that for a number input in graph screen:

Code:
:FnOff
:DelVar Y0
:" ->Str1                 //1 Space after "
:Repeat A=105 or A=21
:Text(1,1,Str1,"[                          //3 Spaces after [
:getKey->A
:Text(1,1,Str1,"                          //3 Spaces after "
:If A=23 or A=72 or A=73 or A=74 or A=82 or A=83 or A=84 or A=92 or A=93 or A=94 or A=102 or A=103 or A=104
:Then
:If A=23
:Then
:If length(Str1)>1
:sub(Str1,1,length(Str1)-1)->Str1
:Else
:If not(A=104 and length(Str1)>1
:Then
A-70->A
Str+sub(" 789             456                 123                0.-,A.1)->Str1 //1 Space after ", 7Spaces after 789, 7 Spaces after 456, 7 Spaces after 123, - is the white key
:End
:End
:End
:End
:sub(Str1,2,length(Str1)-1)->Str1
:String>Equ(Str1,Y0
:FnOff
:Text(10,10,A

Hope you'll like it! Smile
For starters, we can change:
Code:
:If A=23 or A=72 or A=73 or A=74 or A=82 or A=83 or A=84 or A=92 or A=93 or A=94 or A=102 or A=103 or A=104
to:

Code:
If (max(int(.1A)={7,8,9,10}) and max(10fPart(.1A)={2,3,4})) or A=23
We can also change
Code:
A-70->A
Str+sub(" 789             456                 123                0.-,A.1)->Str1 //1 Space after ", 7Spaces after 789, 7 Spaces after 456, 7 Spaces after 123, - is the white key
to:

Code:
sub("7894561230.-",3(int(.1K)-7)+10fPart(.1K)-1
(or)
sub("7894561230.-",3int(.1K)-21+10fPart(.1K)-1
(or)
sub("7894561230.-",3int(.1K)-22+10fPart(.1K
what do int( and fpart( do?
Sorunome wrote:
what do int( and fpart( do?
int() returns the number rounded down to the nearest integer. int(3.2) = 3, int(10.01) = 10, int(-2.2) = -3. fPart() returns just the fractional part of a number. fPart(3.2) = 0.2, fPart(10.01) = 0.01, fPart(-2.2) = 0.2. Finally, iPart() returns just the integer part of a number. iPart(3.2)=3, iPart(10.01) = 10, iPart(-2.2) = -2. Notice the difference between iPart() and int() for negative numbers.

Code:
A=23 or 2>abs(5-abs(10-abs(A-88


Code:
sub("-123456789D0.",1+round(13fPart(A/13)),1


(The "D" would be returned by pressing [DEL].)
Sorunome wrote:
String to Variable

Code:

:FnOff
:DelVar Y0
:Input Str1
:String>Equ(Str1,Y0
:Y0->A
:Disp A

Note that if you type in something like 3+7 for String1 A is 10. Srry if that is added already.

Just do expr(Str1 . Wink
Weregoose wrote:

Code:
A=23 or 2>abs(5-abs(10-abs(A-88


Code:
sub("-123456789D0.",1+round(13fPart(A/13)),1


(The "D" would be returned by pressing [DEL].)


:S What does abs( do?
Sorunome wrote:
Weregoose wrote:

Code:
A=23 or 2>abs(5-abs(10-abs(A-88


Code:
sub("-123456789D0.",1+round(13fPart(A/13)),1


(The "D" would be returned by pressing [DEL].)


:S What does abs( do?

Here are a few examples:
abs(0 becomes 0
abs(27 becomes 27
abs(-14 becomes 14
abs(-1000 becomes 1000
If a number is negative, abs( makes it positive.
Oh i see. In German it is "Betrag". Very Happy Thanks!
Weregoose, an amazing job on that optimization, as usual. Smile
Is there any shourter way for:

Code:
If C-M>=70 or C-N>=70 or C-O>=70 or C-P>=70 or C-Q>=70 or C-R>=70 or C-S>=70 or C-T>=70

Plz help!
Absolutely. Try this:


Code:
If 70<=max(C-{M,N,O,P,Q,R,S,T
Not quite right. But this works:

Code:
If max(70<=C-{M,N,O,P,Q,R,S,T
Weregoose, for one of the first times ever, I'm not convinced that I'm incorrect. I believe that the max() will return the largest of the differences, and if the largest is greater than or equal to 70, the statement is true. Yours merely evaluates the inequality per-element, but I believe it is the same.
Actually, I think Kerm's is right, and I think it might even be faster. His will return true if at least on of those equations is greater than or equal to 70, and it only does an 8 element max and 1 comparison; whereas yours is going to do an 8 element max, and 8 comparisons.
merthsoft wrote:
Actually, I think Kerm's is right, and I think it might even be faster. His will return true if at least on of those equations is greater than or equal to 70, and it only does an 8 element max and 1 comparison; whereas yours is going to do an 8 element max, and 8 comparisons.
Yeah, those are the lines along which I was thinking as well. Smile I'm about 80% sure Weregoose will swoop in with stuff we overlooked, though.
Wow, you're right; the two are interchangeable.

Now I suppose I'm obligated to find something better.

...

I got nothing. Rolling Eyes
Weregoose wrote:
Wow, you're right; the two are interchangeable.

Now I suppose I'm obligated to find something better.

...

I got nothing. Rolling Eyes
I know! You're as surprised as I am that I was right! Wink
Thx for youre help!
  
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
» Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 13, 14, 15  Next
» View previous topic :: View next topic  
Page 7 of 15
» 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