The fix you ended up implementing there is more or less what I would have suggested, had I noticed the problem that you were having. Apologies for not noticing the pending issue you discussed in the topic sooner, but nice job on figuring it out yourself.
Thanks! I find that this text wrapper/letter wrapper is not only compatible with monochome and the color calculator, but also faster and better that the text wrapper offered at http://tibasicdev.wikidot.com/text-wrapper or here. I based some of the above code from your post here.
Electromagnet8 wrote:
Thanks! I find that this text wrapper/letter wrapper is not only compatible with monochome and the color calculator, but also faster and better that the text wrapper offered at http://tibasicdev.wikidot.com/text-wrapper or here. I based some of the above code from your post here.
In that case, I recommend that you post up your routine in our TI-BASIC Useful Routines thread for everyone else to find. Smile
This was discussed a bit on SAX but the problem was not resolved.

I am trying to store a value from a list to a real variable (A-Z, theta). The real variable is to be selected from a string. The string is not always the same.

I originally had:

Code:
For(X,1,dim(ʟQ(X
ʟQ(X)→sub(Str9,1,X
End

For example, if ʟQ is {3,1,4} and Str9 is "QNP", I would like to store 3 into Q, 1 into N, and 4 into P.

The following code was proposed.

Code:
expr(sub(Str9,1,X->ʟQ(X)

However, this takes the value of the real variables and stores them into the list.

After some searching, I found this.
It is quite simple to do this with an assembly code snippet, but I don't believe it is possible to do in Basic. Here's some hex code if you really need to do it this way: Hope this helps somewhat! Smile

TI-Basic Developer wrote:

ListToVars 2


Code:
EFC541
3EAA327984
D7300F
3E40061B21EC86
3C772310FB
11EA861313D5
EFD74A
FE01C0
1AFE1B38023E1B
EB232347
D11A13D5
C5E5F5
EFC541
F1
327984
D73003
EF0F43
E1010900EDB0
C110E3
D1C9


If Str1 contains the list of variables to write to and L1 has the list of values to write, this program will write the values to the variables. For example:
:"ADCZQGB→Str1
:{0,1,1,2,3,5,8
:Asm(prgmL2V2
Then result will be:
: A is 0
: D is 1
: C is 1
: Z is 2
: Q is 3
: G is 5
: B is 8
Thanks MateoConLechuga! This code does indeed work on a TI-84+SE. However, this means that I will have to have a separate assembly program in lieu of code I was hoping to be within the main program. Also, I would like the program to be compatible with both monochrome calculators and the TI-84+CSE.
I have tried a technique that made sense to me at the time. However, I have run into a problem that puzzles me as much as this request itself.

I have tried to do the following. I manually defined Y₁ as →.

Code:
Equ►String(Y₁,Str1
expr("6"+Str1+"A

However, this results in a syntax error.

Without the expr(,

Code:
"6"+Str1+"A
results in 6→A. I assume this is a string.
If I try to do

Code:
expr(Ans
I get a syntax error.
If I type in manually the following:

Code:
expr("6→A
The output is 6 which indicates that 6 was stored into A.
If I type in the following:

Code:
expr("6→A"
or
expr("6→A")
I get a syntax error.
The reason you got a syntax error in the first example is because "6"+Str1+A will return a Data Type error when entered by itself, so when used in the expr() command, it gave a syntax error.

The reason you got a syntax error in the second example is because you are putting 6 into A, but taking the expression of 6->A, and since -> doesn't have anything to do with numbers, you get a syntax error.
I just realized that I overlooked something. The expr() evaluates
Code:
expr("6→A
as
Code:
expr("6")→A
. This would explain why
Code:
expr("6→A"
or
expr("6→A")
will not work. Oh well...

Are there any other workarounds to storing a number to a specified variable chosen from a string?
No, I cannot think of a way to do this except through a bunch of 'if' statements. It would be relatively easy to modify asm to support either the CSE or monochrome, but I completely understand how nice it would be to have it within your main program. I wish that I knew some uber-cool basic trick for this, but I've been stumped by this problem for a while. Sad
I have been working on something along the lines of a solver involving multiple equations.

As of now, I have the following code that works.
Code:
Xmin+ᴇ2∆X<Xmax→|N               //detects calculator model
StoreGDB GDB1
ClrDraw:AxesOff:FnOff
PlotsOff :GridOff

"R₁,H₁,V₁,R,H,V,dR/dT,dH/dT,dV/dT   //list of variables
Ans→Str0
ClrDraw
Text(0,0,"2ND-EDIT | ENTER-REFRESH
{1→ʟQ
inString(Str0,",                //beginning of routine to separate variables
Repeat not(Ans
  Ans+1→ʟQ(1+dim(ʟQ
  inString(Str0,",",Ans+1
End
2+length(Str0→ʟQ(1+dim(ʟQ
dim(ʟQ)-1→Q
For(θ,1,Ans                     //diplay string of variables
  Text(θ6(|N+1),4(|N+1),sub(Str0,ʟQ(θ),ʟQ(θ+1)-1-ʟQ(θ
End
6(|N+1→X                        //initializes the cursor position
DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar I
Repeat max(K={45                //[Clear] quits the program
  Text(X,0,"►
  Repeat Ans:getKey→K:End
  Text(X,0,"   "                //erases cursor
  X+(6|N+6)((Ans=34 and X<6Q(|N+1))-(Ans=25 and X>6(|N+1→X

  If max(K={21,105:Then
    0→J     //0 is stored to variable to be refreshed: to fulfill If statement
    If K=21:Input "VALUE:",J    //Requests value of variable at cursor
    X/(6|N+6                    //Cursor position relative to variables
    If Ans=1:J→A
    If Ans=2:J→B
    If Ans=3:J→C
    If Ans=4:J→D
    If Ans=5:J→E
    If Ans=6:J→F
    If Ans=7:J→G
    If Ans=8:J→H
    If Ans=9:J→I

    If 1=sum(not({A,B,D,E:Then  //ensures that only one variable is 0
      expr("solve(D/A-E/B,"+sub("ABDE",max({not(A),2not(B),3not(D),4not(E)}),1)+",{ᴇ⁻9,ᴇ9
      If not(A:Ans→A
      If not(B:Ans→B
      If not(D:Ans→D
      If not(E:Ans→E
    End

    If 1=sum(not({A,B,C:Then
      expr("solve(1/3πA²B-C,"+sub("ABC",max({not(A),2not(B),3not(C)}),1)+",{ᴇ⁻9,ᴇ9
      If not(A:Ans→A
      If not(B:Ans→B
      If not(C:Ans→C
    End

    If 1=sum(not({D,E,F:Then
      expr("solve(1/3πD²E-F,"+sub("DEF",max({not(D),2not(E),3not(F)}),1)+",{ᴇ⁻9,ᴇ9
      If not(D:Ans→D
      If not(E:Ans→E
      If not(F:Ans→F
    End

    If 1=sum(not({A,B,D,G,I:Then
      expr("solve(BπD²G/A-I,"+sub("ABDGI",max({not(A),2not(B),3not(D),4not(G),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
      If not(A:Ans→A
      If not(B:Ans→B
      If not(D:Ans→D
      If not(G:Ans→G
      If not(I:Ans→I
    End

    If 1=sum(not({A,B,E,H,I:Then
      expr("solve(A²πE²H/B²-I,"+sub("ABEHI",max({not(A),2not(B),3not(E),4not(H),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
      If not(A:Ans→A
      If not(B:Ans→B
      If not(E:Ans→E
      If not(H:Ans→H
      If not(I:Ans→I
    End
     
    {A,B,C,D,E,F,G,H,I→A
    For(θ,1,Q                   //output values of variables
      Text(θ6(|N+1),5(|N+1)max(DeltaList(ʟQ)),ʟA(θ),"                                "
    End
  End
End

This particular code solves a related rates problem involving a conical container. I created a workaround of having the wrong value stored into a variable by adding the option to refresh the variable where the cursor is at. I am hoping to eliminate this but I cannot seem think of a method where this can be done.
I tested with the following values:

Code:
R1=1.5, H1=4, V1=9.424778
R=1.125, H=3, V=3.9760782
dR/dT=-0.1886281, dH/dT=-0.5030082, dV/dT=-2
Would you mind telling us a little bit more about what you're trying to do and what's not working about it? Which is the part of the code that stores the wrong value, the part that you want to eliminate?
I forgot to add that this program is akin to FormulaPro for the TI-Nspire.
KermMartian wrote:
Would you mind telling us a little bit more about what you're trying to do and what's not working about it?

The program currently works fine for the first time through. However, if you want to edit a value, you must refresh each variable, which stores 0 into the variable to be refreshed. This is to force the If 1=sum(not({<list of variables>})) to be true and execute the code that follows the If-Then statement. It is not possible to refresh every variable every time because that would store 0 into every variable (Inputing a value of 0 is the same as refreshing). However, if every variable can be refreshed individually without changing any of the values, the solution is complete until the user inputs a different value for any variable. Here are screenshots taken with jsTIfied where I input some values, refresh the ones I need to, change a value, and refresh the variables.


Quote:
Which is the part of the code that stores the wrong value, the part that you want to eliminate?

The code in question is:

Code:
If max(K={21,105:Then
  0→J     //0 is stored to variable to be refreshed: to fulfill If statement
  If K=21:Input "VALUE:",J    //Requests value of variable at cursor
  X/(6|N+6                    //Cursor position relative to variables
  If Ans=1:J→A
  If Ans=2:J→B
  If Ans=3:J→C
  If Ans=4:J→D
  If Ans=5:J→E
  If Ans=6:J→F
  If Ans=7:J→G
  If Ans=8:J→H
  If Ans=9:J→I

  If 1=sum(not({A,B,D,E:Then  //ensures that only one variable is 0
    expr("solve(D/A-E/B,"+sub("ABDE",max({not(A),2not(B),3not(D),4not(E)}),1)+",{ᴇ⁻9,ᴇ9
    If not(A:Ans→A
    If not(B:Ans→B
    If not(D:Ans→D
    If not(E:Ans→E
  End

  If 1=sum(not({A,B,C:Then
    expr("solve(1/3πA²B-C,"+sub("ABC",max({not(A),2not(B),3not(C)}),1)+",{ᴇ⁻9,ᴇ9
    If not(A:Ans→A
    If not(B:Ans→B
    If not(C:Ans→C
  End

  If 1=sum(not({D,E,F:Then
    expr("solve(1/3πD²E-F,"+sub("DEF",max({not(D),2not(E),3not(F)}),1)+",{ᴇ⁻9,ᴇ9
    If not(D:Ans→D
    If not(E:Ans→E
    If not(F:Ans→F
  End

  If 1=sum(not({A,B,D,G,I:Then
    expr("solve(BπD²G/A-I,"+sub("ABDGI",max({not(A),2not(B),3not(D),4not(G),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
    If not(A:Ans→A
    If not(B:Ans→B
    If not(D:Ans→D
    If not(G:Ans→G
    If not(I:Ans→I
  End

  If 1=sum(not({A,B,E,H,I:Then
    expr("solve(A²πE²H/B²-I,"+sub("ABEHI",max({not(A),2not(B),3not(E),4not(H),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
    If not(A:Ans→A
    If not(B:Ans→B
    If not(E:Ans→E
    If not(H:Ans→H
    If not(I:Ans→I
  End
     
  {A,B,C,D,E,F,G,H,I→A
  For(θ,1,Q                   //output values of variables
    Text(θ6(|N+1),5(|N+1)max(DeltaList(ʟQ)),ʟA(θ),"                                "
  End
End


Is there a way to eliminate the need of manually refreshing a variable?
*bump

I worked on this a bit. Currently, I can solve for all of the variables without the need of refreshing/updating. However, when I try to edit a value, it will only solve for the associated variables to the single equation. The method I am using now is creating a list of the most recently edited variables and refreshing from the bottom of the stack until all the variables are solved for.

Here is the current code:

Code:
6(|N+1→X
seq(X,X,1,Q→C
DelVar ʟA
Q→dim(ʟA
DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar I
Repeat max(K={45
  Text(X,0,"►
  Repeat Ans:getKey→K:End
  Text(X,0,"   "
  X+(6|N+6)((Ans=34 and X<6Q(|N+1))-(Ans=25 and X>6(|N+1→X

  If max(K={21,105:Then
    0→J
    If K=21:Then
      Input "VALUE:",J
      X/(6|N+6→K
      max(seq(X(Ans=ʟC(X)),X,1,dim(ʟC→L
      If L≥1 and L≤dim(ʟC:augment(seq(ʟC(X+(X≥Ans)),X,1,dim(ʟC)-1),{ʟC(Ans→ʟC
      ʟA→ʟB
    End
    X/(6|N+6→K
    If K=1:J→A
    If K=2:J→B
    If K=3:J→C
    If K=4:J→D
    If K=5:J→E
    If K=6:J→F
    If K=7:J→G
    If K=8:J→H
    If K=9:J→I
    0→L
    Repeat not(min(ʟA=ʟB)
      If 1=sum(not({A,B,D,E:Then
        expr("solve(D/A-E/B,"+sub("ABDE",max({not(A),2not(B),3not(D),4not(E)}),1)+",{ᴇ⁻9,ᴇ9
        If not(A:Ans→A
        If not(B:Ans→B
        If not(D:Ans→D
        If not(E:Ans→E
      End

      If 1=sum(not({A,B,C:Then
        expr("solve(1/3πA²B-C,"+sub("ABC",max({not(A),2not(B),3not(C)}),1)+",{ᴇ⁻9,ᴇ9
        If not(A:Ans→A
        If not(B:Ans→B
        If not(C:Ans→C
      End

      If 1=sum(not({D,E,F:Then
        expr("solve(1/3πD²E-F,"+sub("DEF",max({not(D),2not(E),3not(F)}),1)+",{ᴇ⁻9,ᴇ9
        If not(D:Ans→D
        If not(E:Ans→E
        If not(F:Ans→F
      End

      If 1=sum(not({A,B,D,G,I:Then
        expr("solve(BπD²G/A-I,"+sub("ABDGI",max({not(A),2not(B),3not(D),4not(G),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
        If not(A:Ans→A
        If not(B:Ans→B
        If not(D:Ans→D
        If not(G:Ans→G
        If not(I:Ans→I
      End

      If 1=sum(not({A,B,E,H,I:Then
        expr("solve(A²πE²H/B²-I,"+sub("ABEHI",max({not(A),2not(B),3not(E),4not(H),5not(I)}),1)+",{ᴇ⁻9,ᴇ9
        If not(A:Ans→A
        If not(B:Ans→B
        If not(E:Ans→E
        If not(H:Ans→H
        If not(I:Ans→I
      End
     
      {A,B,C,D,E,F,G,H,I→A
      L+1→L
      ʟC(L→J
   
      If J=1:0→A
      If J=2:0→B
      If J=3:0→C
      If J=4:0→D
      If J=5:0→E
      If J=6:0→F
      If J=7:0→G
      If J=8:0→H
      If J=9:0→I
     
    End
    For(θ,1,Q
      Text(θ6(|N+1),5(|N+1)max(DeltaList(ʟQ)),ʟA(θ),"                               
    End
  End
End
*bump
I took a look at Formula Pro and found out that a user is unable to edit a variable that was solved for by other variables. Instead, I think it stores the manipulated variables into a list and only allows the user to update those.
I tried to apply the same concept to my program.
When the user edits a value, the value of one is stored to a list that represents which variables have been directly edited. Any variable that is not in the list is set to zero before all of the solving. Although it takes more time to set most of the variables to zero and solve, it is far better than trying to continually go through the solve statements until all of the variables are solved for. Now, I have a complete, working program that is satisfactory to me. I took a few animated screenshots from jsTIfied but might post better ones here.

Edit: Screenshots taken with Wabbitemu
  
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 2 of 2
» 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