Not displaying text string correctly
BlitzPlus Forums/BlitzPlus Programming/Not displaying text string correctly| 
 | ||
| In this source: Graphics 640,240,16,2 SeedRnd MilliSecs() ;Text 0,0,JABNONFORMATTEDCHRS$(10,2) Write JABNONFORMATTEDCHRS$(10,2) WaitKey:End Function JABNONFORMATTEDCHRS$(CHL=1,LI=1,N=0,S=0,C=0) NN=Rand(1,95) For UU=1 To LI For GG=1 To CHL If N=1 Then NN=Rand(1,10):RT$=RT$+Chr$(47+NN) If (C=1 Or C=2) Then NN=Rand(1,26):RT$=RT$+Chr$(96+NN) If C=0 Then NN=Rand(1,26):RT$=RT$+Chr$(64+NN) If S=1 Then NN=Rand(1,33) If NN=>31 And NN<=46 Then RT$=RT$+Chr$(NN) If NN>=57 And NN<=63 Then RT$=RT$+Chr$(NN) If NN>=90 And NN<=95 Then RT$=RT$+Chr$(NN) If NN>=122 And NN<=125 Then RT$=RT$+Chr$(NN) Next RT$=RT$+Chr$(10)+Chr$(13) Next Return RT$ End Function the printout does not two distinct lines of random characters, it shows one string of 20 characters.. I want to show a string of 10 characters on each line in either graphics mode but one does not recognize the chr$(10)+chr$(13) for some reason. | 
| 
 | ||
| Write/Print/Text do not support linefeeds.  They can only be used to draw a single line of text.  If you want two lines of text, you'll have to draw them manually. | 
| 
 | ||
| It does work for the print command. 
Graphics 640,480,16,2
RT$=String$("G",20)
RT$=RT$+Chr$(10)+Chr$(13)
RT$=RT$+String$("H",20)
;Text 0,0,RT$
Print RT$
WaitKey:End
I thought that it might be the Function Call that was interfering with the program. | 
| 
 | ||
| Never mind. the solution was this: Function JABNONFORMATTEDCHRS$(CHL=1,LI=1,N=0,S=0,C=0) NN=Rand(1,95) For UU=1 To LI For GG=1 To CHL If N=1 Then NN=Rand(1,10):RT$=RT$+Chr$(47+NN) If (C=1 Or C=2) Then NN=Rand(1,26):RT$=RT$+Chr$(96+NN) If C=0 Then NN=Rand(1,26):RT$=RT$+Chr$(64+NN) If S=1 Then NN=Rand(1,33) If NN=>31 And NN<=46 Then RT$=RT$+Chr$(NN) If NN>=57 And NN<=63 Then RT$=RT$+Chr$(NN) If NN>=90 And NN<=95 Then RT$=RT$+Chr$(NN) If NN>=122 And NN<=125 Then RT$=RT$+Chr$(NN) Next Text 5,5+(12*(UU-1)),RT$+Chr$(10)+Chr$(13):RT$="" Next ;Return RT$ End Function The line needed to be printed twice inside of the Function. Appending it all into one string with a embedded chr$(13)+chr$(10) is another issue. I'll go from here. Last edited 2013 |