sub(str4,B,1) ;ERR: DOMAIN, (B=7 and length(str4)=36)
-----
sub(str4,7,1) ;works fine with no change to the string
-----
7 -> B
sub(str4,B,1) ;works fine
-----
int(B -> B
sub(str4,B,1) ;works fine
X+1-6(X=6) -> X
... and nothing happens. (I'm not totally sure that's true, but I do know that there is no writeback if it DOES do something)Well the problem with the sub( command seems like somewhere you are generating a decimal part and sub( can't have those. It has to be an integer. So I would advise using iPart( instead of int( because it can have weird effects in some situations, I don't remember what they are though.
As for that second thing with the storing to the variable thing I'm not sure I understand what you mean by nothing is happening. Like that one isn't getting stored to the variable when the variable equals six? Or something else?
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->Str3
:"CIPHER-KEY-36-LETTERS+NUMBERS->Str4
:Prompt Str1
:" ->Str5
:For(A,1,length(Str1),2)
:A-1->A
:Repeat B or A=length(Str1)
:A+1->A
:sub(Str1,A,1->Str1
:int(inString(Str4,Str2->B
:If not(B
:Str5+Str2->Str5
:End
:If B
:Then
:A->D
:If A=length(Str1)
:Str1+A->Str1
:A-1->A
:Repeat C or A+2=length(Str1
:A+1->A
:sub(Str1,A+1,1)->Str2
:int(inString(Str4,Str2->C
:End
:If not(C
:Then
:Str1+A->Str1
:int(inString(Str4,"A->C
:End
:int((B-1)/6->T
:int(6fPart((B-1)/6)+1->S
:int((C-1)/6->U
:int(6fPart((C-1)/6)+1->V
:If not(S=U and T=V)
:Then
:If T=V
:Then
:S+1-6(S=6)->S
:U+1-6(U=6)->U
:Else
:If S=U
:Then
:T+1-6(T=5)->T
:V+1-6(V=5)->V
:Else
:S+U->S
:S-U->U
:S-U->S
:End
:End
:6T+S->B
:6U+S->C
:End
:int(B->B
:Str5+sub(Str4,B,1)->Str5
:If A-D<0
:Str5+sub(Str1,D+1,A-D)->Str5
:int(C->C
:Str5+sub(Str4,C,1)->Str5
:End
:End
:Disp Str5
iPart( and int( have the same effect for positive numbers, so that's not it. :)
It looks to me like fPart( is not returning the right number. Try this when it crashes:
Figure out which variable was being used (it's probably the bad one).
Go into the Solver ([Math] [0])
Type that variable into the equation
Scroll up or down (I forget which) and look at all the digits of precision the calc has. Here you can see what's happening to these numbers.
Fix: put a round(......,0 around the statement with the fpart(. (Ex: int(6fPart((B-1)/6)+1->S changes to round(6fPart((B-1)/6)+1,0->S)
if one_number = 9
that_number=8
if the_other = 8
the_other=7
end
else
everything works
end
Kz1 pxn lhxm ztkq pf zhmjuewppr vppo ynssp2a.P