How To

Here's an STR$ Subprogram with fixed digits

2

SP4CEBAR 2022-09-30 10:52 (Edited)


SUB STR_DIG(T,T$,N)
  Z$=""
  FOR I=0 TO N
    Z$=Z$+"0"
  NEXT I
  T$=RIGHT$(Z$+STR$(T),N)
END SUB

SUB STR_2DIG(T,T$)
  T$=RIGHT$("0"+STR$(T),2)
END SUB```


SP4CEBAR 2022-09-30 10:56 (Edited)

The first one works for N digits and has to generate an N-digit string of zeroes, the generator could be more optimized
The second one generates 2-digit strings


qwaffe 2022-10-01 03:38 (Edited)

SUB STR_DIG_6(T,T$,N)
  T$=RIGHT$(STR$(1000000+T),N)
END SUB

works for N up to 6


Timo 2022-10-01 11:22

Still keep in mind that using the NUMBER command is better for performance. If it’s possible in your cases.


SP4CEBAR 2022-10-02 07:30

In my case, I wanted to do some string processing afterward, so this worked well


Log in to reply.