We know the length of the substring wont be an issue, since we are only taking 1 character instead of all 5 (I purposely put 1 instead of 5 so you woul hopefully be able to learn something).

We know the inputs will be 1-13.75. So the iPart will be 1-13, and the iPart-1 will be 0-12; we know the starting positions will range from 1 to 61; and the string should be 66 characters long.

Therefore, the only possibe explanation is that the input isnt right; the only part of input that changes is Ans. So whatever is in ans must be wrong

]]>but I get invalid dim error using this :sub("ACE _ _2 _ _ _ _ 3 _ _ _ _ 4 _ _ _ _ 5 _ _ _ _ 6 _ _ _ _ 7 _ _ _ _8 _ _ _ _ 9 _ _ _ _10 _ _ _ JACK _ QUEENKING _",1+5iPart(Ans-1),1

]]>`Disp "Value:",sub("A23456789TJQK",iPart(Ans),1`

Another note is that your list should not start at 0.25. There are 13 values of cards, so if you start with {0.0,0.25,0.5} your last value should be 12.75. If your list starts with {1,1.25,1.5} your last value should be 13.75.

I'm going to show you them again, but part of learning how to write programs is to do the calculations yourself:

]]>:Disp "Value:", sub("ACE _ _2 _ _ _ _ 3 _ _ _ _ 4 _ _ _ _ 5 _ _ _ _ 6 _ _ _ _ 7 _ _ _ _8 _ _ _ _ 9 _ _ _ _10 _ _ _ JACK _ QUEENKING _",1+(Ans-2)*5,5

]]>⸤DECK

(0.25, 0.50, 0.75, 1.0… 13.75)

:randInt(1,52→T

:⸤DECK(T

:Disp "Value:", sub("ACE _ _2 _ _ _ _ 3 _ _ _ _ 4 _ _ _ _ 5 _ _ _ _ 6 _ _ _ _ 7 _ _ _ _8 _ _ _ _ 9 _ _ _ _10 _ _ _ JACK _ QUEENKING _",1+(Ans-2)*5,5

:Disp "Suit:", sub("SPADES _ _ HEARTS _ _ DIAMONDSCLUBS _ _ _",32fPart(Ans)+1,8

//_ = 1 space

I run and get a Domain Error how do I fix that?

So, when you take the fParts, you get a list that looks like {0,.25,.5,.75,0,…,.5,.75}

Therefore, when you take 4fPart, you get {0,1,2,3,….,2,3} + 1 would be {1,2,3,4,1,2,3,4,1,2,3,4}

Now lets take a look at what that looks like in the sub function:

`sub("SPADES HEARTS DIAMONDSCLUBS ",1,8 returns "SPADES_H" sub("SPADES HEARTS DIAMONDSCLUBS ",2,8 returns "PADES_HE" sub("SPADES HEARTS DIAMONDSCLUBS ",3,8 returns "ADES_HEA" sub("SPADES HEARTS DIAMONDSCLUBS ",4,8 returns "DES_HEAR"`

The first thing to do is to make all the elements in your string the same length, this would make your string:

"SPADES_ _HEARTS_ _DIAMONDSCLUBS_ _ _" where _ represents a space

The second thing to do is figure out how to turn {1,2,3,4} into each of the starting positions {1,9,17,25}. This would be 8*Ans+1. However, we know that Ans is actually 4fPart(Ans)+1, so we can substitute back and get 8*4fPart(Ans)+1 which simplifies to 32fPart(Ans)+1

`8(fPart(Ans)≠0)*4fPart(Ans)+1 If fPart(Ans)=.00; 32fPart(Ans)+1 = 32(.00)+1 = 1 If fPart(Ans)=.25; 32fPart(Ans)+1 = 32(.25)+1 = 9 If fPart(Ans)=.50; 32fPart(Ans)+1 = 32(.50)+1 = 17 if fPart(Ans)=.75; 32fPart(Ans)+1 = 32(.75)+1 = 25`

Therefore, the final code would be:

`randInt(1,52->T ⸤DECK(T Disp "Value:", sub("A23456789TJQK",int(Ans),1 Disp "Suit:", sub("SPADES HEARTS DIAMONDSCLUBS ",32fPart(Ans)+1,8`

An easier way to do this would be to change your list, so instead of having {1,1.25,1.5,1.75,2,2.25,….13.5,13.75} you would have {1.01,1.09,1.17,1.25,2.01,2.09,….13.17,13.25}

That would mean your code could be

`randInt(1,52->T ⸤DECK(T Disp "Value:", sub("A23456789TJQK",int(Ans),1 Disp "Suit:", sub("SPADES HEARTS DIAMONDSCLUBS ",fPart(Ans)e2,8`

:⸤DECK(T

:Disp "Value:", sub("A23456789TJQK",int(Ans),1

:Disp "Suit:", sub("SPADES HEARTS DIAMONDSCLUBS ",4fpart(Ans)+1,8

When I run this I get

ADES HE

SPADES