A little more info on your code would be helpful. From what I gather, you have a list of cards in a list which looks something like: {1,1.25,1.5,1.75,2,2.25,….13.5,13.75}
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