Posted: 6th Nov 2002 21:07
My RTPrint command works just like the TEXT command in DB

only it can print in many styles and colors in the same command! by embedding byte script commands into the text
to print! see example below. Put it in DB and give it a run
I made it easier to embed by providing three functions to encode your strings: Style$() Color$() and Size$() functions.

+ Code Snippet
dim A$(10)

A$(0)=Size$(20)+Color$(0,0,255)+"Russel "
A$(0)=A$(0)+Color$(255,0,0)+Style$(2)+Chr$(34)+"IronHoof"+Chr$(34)+" "+Style$(0)
A$(0)=A$(0)+Color$(0,0,255)+"Hamrick "+Color$(0,255,0)+Style$(2)+"2002"

A$(1)=Size$(10)+Color$(255,0,150)+Style$(2)+"This is a small example of a byte script"
A$(1)=A$(1)+" imprinted rich text."

A$(2)=Style$(0)+Color$(255,255,255)+"It "+Color$(255,255,0)+Size$(40)+Style$(2)+"CAN "
A$(2)=A$(2)+Size$(10)+Color$(255,255,255)+Style$(0)+"print many styles all in one string."

a$(3)=Color$(150,0,150)+"In all "+Color$(150,0,0)+"C"+Color$(255,0,0)+"O"+Color$(0,150,0)
a$(3)=a$(3)+"L"+Color$(0,255,0)+"O"+Color$(0,0,150)+"R"+Color$(0,0,255)+"S"

a$(4)=Color$(184,64,106)+"This example is over "+Style$(2)+Size$(60)+"GOODBYE!"
for i=0 to 10
RTPrint(10,10+(I*40),A$(i))
next i

end


function RTPrint(X,Y,TEXT$)
L=1
GONEX:
C$=MID$(TEXT$,L):TMP$=""
if c$=chr$(24) then set text to italic:inc l,1
if C$=chr$(26) then set text to bold:inc l,1
if c$=CHR$(27) then set text to normal:inc l,1
if C$=chr$(25)
R$=MID$(TEXT$,L+1):G$=MID$(TEXT$,L+2):B$=MID$(TEXT$,L+3):inc L,4
R=ASC(R$):G=ASC(G$):B=ASC(B$):ink rgb(R,G,B),0
endif
if C$=chr$(23)
S$=MID$(TEXT$,L+1):set text size asc(S$):inc L,2
endif
junction:
C$=MID$(TEXT$,L):IS=0
if asc(C$)>31 and asc(C$)255 then size=255
TMP$=CHR$(23)+CHR$(size)
endfunction TMP$
Posted: 6th Nov 2002 21:10
That didnt come out so good letme try agian I think i missed
when i copied.

+ Code Snippet
dim A$(10)

A$(0)=Size$(20)+Color$(0,0,255)+"Russel "
A$(0)=A$(0)+Color$(255,0,0)+Style$(2)+Chr$(34)+"IronHoof"+Chr$(34)+" "+Style$(0)
A$(0)=A$(0)+Color$(0,0,255)+"Hamrick "+Color$(0,255,0)+Style$(2)+"2002"

A$(1)=Size$(10)+Color$(255,0,150)+Style$(2)+"This is a small example of a byte script"
A$(1)=A$(1)+" imprinted rich text."

A$(2)=Style$(0)+Color$(255,255,255)+"It "+Color$(255,255,0)+Size$(40)+Style$(2)+"CAN "
A$(2)=A$(2)+Size$(10)+Color$(255,255,255)+Style$(0)+"print many styles all in one string."

a$(3)=Color$(150,0,150)+"In all "+Color$(150,0,0)+"C"+Color$(255,0,0)+"O"+Color$(0,150,0)
a$(3)=a$(3)+"L"+Color$(0,255,0)+"O"+Color$(0,0,150)+"R"+Color$(0,0,255)+"S"

a$(4)=Color$(184,64,106)+"This example is over "+Style$(2)+Size$(60)+"GOODBYE!"
for i=0 to 10
RTPrint(10,10+(I*40),A$(i))
next i

end


function RTPrint(X,Y,TEXT$)
L=1
GONEX:
C$=MID$(TEXT$,L):TMP$=""
if c$=chr$(24) then set text to italic:inc l,1
if C$=chr$(26) then set text to bold:inc l,1
if c$=CHR$(27) then set text to normal:inc l,1
if C$=chr$(25)
R$=MID$(TEXT$,L+1):G$=MID$(TEXT$,L+2):B$=MID$(TEXT$,L+3):inc L,4
R=ASC(R$):G=ASC(G$):B=ASC(B$):ink rgb(R,G,B),0
endif
if C$=chr$(23)
S$=MID$(TEXT$,L+1):set text size asc(S$):inc L,2
endif
junction:
C$=MID$(TEXT$,L):IS=0
if asc(C$)>31 and asc(C$)<127
TMP$=TMP$+C$:IS=1
endif
if IS=1 and L<LEN(TEXT$) then inc l,1:goto junction:
text X,Y,TMP$:X=X+TEXT WIDTH(TMP$)
if L<LEN(TEXT$) then goto GONEX:
endfunction

function Color$(R,G,B)
if R<1 then R=1
if G<1 then G=1
if B<1 then B=1
TMP$=CHR$(25)+CHR$(R)+CHR$(G)+CHR$(B)
endfunction TMP$

function Style$(styl)
if Styl=0 then TMP$=chr$(27)
if Styl=1 then TMP$=chr$(26)
if Styl=2 then TMP$=chr$(24)
endfunction TMP$

function Size$(size)
if size<0 then size=0
if size>255 then size=255
TMP$=CHR$(23)+CHR$(size)
endfunction TMP$
Posted: 6th Nov 2002 21:51
I would lose the : after the 'then goto GONEX:' otherwise you get an error on the next line.

Didn't actually print anything - got a nice black blank screen...
Posted: 6th Nov 2002 21:53
Ah, but its not for DBPro is it???
Posted: 7th Nov 2002 1:13
No its not for DBPRo and you just seen why
I cant get dbpro to work half the time...

Its made for plain ole DB - thats why the : on the end of GONEX works ^_^ "in some programming languages it was nessessary to put the : even after the goto. Its an old habbit hard to break but in DB that dosnt matter "unless our using pro"