0 Members and 1 Guest are viewing this topic.
:sub(Str2,length(Str2)-2,length(Str2)->X:if x="^0":sub(Str2,1,length(Str2)-2)->Str2
I'm writing a small program in TI-BASIC to calculate derivatives, The way I have it so far is that when the final element inputed is to the 1st power, the result is written as x^0. Example: 5x^4+3x^1 would result in 20x^3+3x^0.I'm trying to cut out that last bit but I keep getting an invalid dim error.Here's the code I wrote to parse put that bit.Code: [Select]:sub(Str2,length(Str2)-2,length(Str2)->X:if x="^0":sub(Str2,1,length(Str2)-2)->Str2
sub(Str2,length(Str2)-1,2If Ans="^0sub(Str2,1,length(Str2)-2 -> Str2
isn't last index is supposed to be 1 lower?:sub(Str2,length(Str2)-2,length(Str2)-1->Xlike thisI believe string value starts with 0.
EDIT: super ninja'd
QuoteEDIT: super ninja'd Try Uber ninja'd I just got ninja'd three times over!Thank you everyone. I just started working with the sub( function yesterday so I'm not too familiar with them.