This produces left justified output:
Code: Select all
Format( dwLenFilA, "#########" )
Code: Select all
Right( Space( 9 ) & Format( dwLenFilA, "#########" ), 9 )
Code: Select all
Format( dwLenFilA, "#########" )
Code: Select all
Right( Space( 9 ) & Format( dwLenFilA, "#########" ), 9 )
Code: Select all
#include "vbcompat.bi"
Dim dwLen as ULong = 23456789
Print Format( dwLen, "#########" )
Print Format( dwLen )
Print Str( dwLen )
Print Format( dwLen, "000000000" )
Sleep
Code: Select all
#include "string.bi"
Dim As Long dwLenFilA= 123456, digits = 9
? Right( Space( digits ) & Format( dwLenFilA, "#########" ), digits )
? Space(digits - Len(Str(dwLenFilA))) & dwLenFilA
Sleep
Code: Select all
Dim s As String= Space(9)
RSet s,str(123456)
Print s
sleep
Code: Select all
Right( Space( 9 ) & Str( dwLenFilA ), 9 )
Code: Select all
Strg( dwLenFilA , 9 )
Code: Select all
#define RJstrg( value, numdigs ) Right( Space( numdigs ) & Str( value ), numdigs )
Code: Select all
#include "crt.bi"
function rightset(s as string,n as long,flag as boolean=true) as string
dim as zstring * 100 g
var L=len(s)
if flag then L=0
sprintf(g,"%"+str(n+L)+"s",s)
return g
end function
function setright(s as string,n as long) as string
dim as string g=space(n)
rset g,s
return g
end function
dim as string s(...)={"Mess","about","with","the","C","runtime","press","a","key","to","end"}
for n as long=lbound(s) to ubound(s)
color n+2
print rightset(s(n),20)
next
print
s(4)="FreeBASIC"
for n as long=lbound(s) to ubound(s)
color n+2
print setright(s(n),20)
next
print
sleep
Code: Select all
function setrightL(s as string,n as long,flag as boolean=false) as string
if flag=false then locate ,n-len(s)+1 else locate ,n
return s
end function
function setrightR(s as string,n as long) as string
dim as string g=space(n)
rset g,s
return g
end function
print "Using locate"
locate ,45
print chr(31)
for n as long=10 to 25
print chr(124)+str(sqr(n));setrightL(chr(124)+" = the square root of "+str(n)+chr(124),45)
next
print:print
print "using space"
print
for n as long=10 to 25
print chr(124)+str(sqr(n));setrightR(chr(124)+" = the square root of "+str(n)+chr(124),30)
next
sleep