debluzz
Junior Member
Thanks tsh73 I'll work with it.
Posts: 57
|
zero's
Jan 29, 2021 13:13:48 GMT -5
Post by debluzz on Jan 29, 2021 13:13:48 GMT -5
how do i turn all zero's into a blank space without effecting my other totals with zeros ?
<code>print "# STRFN Hl H2 L1 L2 L3 SEQ PAIR"
print "----------------------------------------------------"
print i1;" ";C1,i1(H1);" ";i1(H2),i1(L1);" ";i1(L2);" ";i1(L3),sequence1;" ";pairs1$
print i2;" ";C2,i2(H1);" ";i2(H2),i2(L1);" ";i2(L2);" ";i2(L3),sequence2;" ";pairs2$
print i3;" ";C3,i3(H1);" ";i3(H2),i3(L1);" ";i3(L2);" ";i3(L3),sequence3;" ";pairs3$
print i4;" ";C4,i4(H1);" ";i4(H2),i4(L1);" ";i4(L2);" ";i4(L3),sequence4;" ";pairs4$
print i5;" ";C5,i5(H1);" ";i5(H2),i5(L1);" ";i5(L2);" ";i5(L3),sequence5;" ";pairs5$
print i6;" ";C6,i6(H1);" ";i6(H2),i6(L1);" ";i6(L2);" ";i6(L3),sequence6;" ";pairs6$
print i7;" ";C7,i7(H1);" ";i7(H2),i7(L1);" ";i7(L2);" ";i7(L3),sequence7;" ";pairs7$
print i8;" ";C8,i8(H1);" ";i8(H2),i8(L1);" ";i8(L2);" ";i8(L3),sequence8;" ";pairs8$
</code>
|
|
|
zero's
Jan 29, 2021 13:22:29 GMT -5
Post by tsh73 on Jan 29, 2021 13:22:29 GMT -5
please post piece of your output as it is and as you want it to be.
(you can write to string then replstr$ "0" with " " - but it could replace 0 in 10, so some thinking is required)
|
|
debluzz
Junior Member
Thanks tsh73 I'll work with it.
Posts: 57
|
zero's
Jan 29, 2021 13:32:58 GMT -5
Post by debluzz on Jan 29, 2021 13:32:58 GMT -5
# STRFN Hl H2 L1 L2 L3 SEQ PAIR ---------------------------------------------------- 1 22 0 22 0 0 0 0 2 14 0 0 0 0 0 0 3 18 0 0 0 0 0 0 4 32 32 0 0 0 0 0 5 5 0 0 0 5 0 0 6 9 0 0 0 0 9 0 7 4 0 0 4 0 0 0 8 16 0 0 0 0 0 0
the SEQ AND PAIR columns are ok
HI,H2,L1,L2,L3 IS the problem
'
|
|
|
zero's
Jan 29, 2021 13:50:40 GMT -5
Post by tsh73 on Jan 29, 2021 13:50:40 GMT -5
you see, if you have 0 divide with spaces - you see columns. but if you replace 0 it with spaces? Will you know last 4 in second-last row in 5th column or 6th? Another thing. some numbers single digit, some double. Normally one should format that to occupy two spaces always. There is a USING for that.
Said that, have a look
1 13 0 11 14 3 0 0 2 23 14 0 0 0 18 0 3 15 0 0 12 17 0 0 4 20 0 0 0 0 0 0 5 10 0 0 0 0 0 0 6 28 0 0 18 0 0 8 7 34 0 0 0 0 0 0 8 11 0 0 0 1 0 18
1 13 11 14 3 2 23 14 18 3 15 12 17 4 20 5 10 6 28 18 8 7 34 8 11 1 18
'replace 0 with space with replstr$ dim d(8,7) for i = 1 to 8 for j = 1 to 7 if j = 1 then d(i,j)=5+int(rnd(0)*30) else r=rnd(0) select case case r<0.1 d(i,j)=int(rnd(0)*10) case r<0.2 d(i,j)=10+int(rnd(0)*10) case else d(i,j)=0 end select end if next next
'ordinary print for i = 1 to 8 print i; " "; for j = 1 to 7 print d(i,j); " "; next print next print
'print to string, then replstr for i = 1 to 8 print i; s$=" " 'so it starts and ends with " " - so begin/end are " 0 " too for j = 1 to 7 s$=s$; d(i,j); " " next 'it seems single replstr$(s$, " 0 ", " ") is not enough while instr(s$, " 0 ") s$=replstr$(s$, " 0 ", " ") wend print s$ next end
|
|
|
zero's
Jan 30, 2021 2:51:33 GMT -5
Post by Rod on Jan 30, 2021 2:51:33 GMT -5
The usual fix for this is to add leading zeros to make each number in the column the same length. Not to use spaces. Spaces are often removed or ignored pay display devices so spoiling the line up. So we need 001 010 and 100 or 01 04 etc.
Pretty sure we have shown this a few times. If you start with a string trim$ it best start with a number make a string of it with str$ pretend “000” so “00004” then take the right most number you need say right$(“00004”,3) gives 004 and all columns line up. Choose values that suit the length of your data.
|
|
Tasp
Full Member
Posts: 215
|
zero's
Jan 30, 2021 5:17:18 GMT -5
Post by Tasp on Jan 30, 2021 5:17:18 GMT -5
Here's a function to prefix with zeros. Pretty sure this was Brandon Parkers code orginially.
'Define the Length of the number numberlength = 6
'Input the inital number input ""; info$
'Prefix the number with zeros then add the initial number info$ = formatLeadingZeros$(numberlength, info$) 'fixed length of info$(), padded with zeros
print info$
END
FUNCTION formatLeadingZeros$(fieldWidth, info$) formatLeadingZeros$=Right$("000000",fieldWidth-Len(info$))+info$ END FUNCTION
|
|