String ausdrucken

Anfängerfragen zum Programmieren mit PureBasic.
Carl
Beiträge: 15
Registriert: 28.10.2013 20:45
Computerausstattung: Windows 7 Professional / Windows 10

AMD FX(tm)-8320 Eight-Core Processor 3,5 Ghz
8 GB Speicher
PureBasic 5.62 (Windows - x64)

String ausdrucken

Beitrag von Carl »

Hallo,
ich möchte einen String zeilenweise ausdrucken. Leider gelingt es mir nicht einen Zeilenumbruch an den Drucker zu senden. Ich habe einiges ausprobiert, komme aber zu keinem Ergebnis.
Der String „Drucke“wird in eine Zeile gedruckt.



Code: Alles auswählen

d$= "test"+"11111"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test= "+"22222"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"333"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"4444"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"5555"+Chr(10)+Chr(13)
Drucke$+d$
Debug Drucke$


If PrintRequester()

  If StartPrinting("")
  
    LoadFont(0, "Arial", 60)
  
    If StartDrawing(PrinterOutput())
      
      BackColor(RGB(255, 255, 255)) 
      FrontColor(RGB(0, 0, 0)) 
      
      DrawingFont(FontID(0))

      DrawText(100, 100, Drucke$)
 
      StopDrawing()
    
    EndIf
    
    StopPrinting()
  EndIf
EndIf
Benutzeravatar
Bisonte
Beiträge: 2430
Registriert: 01.04.2007 20:18

Re: String ausdrucken

Beitrag von Bisonte »

DrawText unterstützt keine Steuerzeichen wie Chr(13) oder Chr(10).

Wenn Du etwas in eine weitere Zeile schreiben möchtest, musst du es mit den Koordinaten sagen...

In deinem Fall etwa so :

Code: Alles auswählen

d$= "test"+"11111"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test= "+"22222"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"333"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"4444"+Chr(10)+Chr(13)
Drucke$+d$
d$= "test"+"5555"+Chr(10)+Chr(13)
Drucke$+d$
Debug Drucke$

If PrintRequester()

  If StartPrinting("")
 
    LoadFont(0, "Arial", 60)
 
    If StartDrawing(PrinterOutput())
     
      BackColor(RGB(255, 255, 255))
      FrontColor(RGB(0, 0, 0))
     
      DrawingFont(FontID(0))
      
      textHoehe = TextHeight("|")
      
      CRLF = CountString(Drucke$, Chr(10)+Chr(13))
      y = 100
      
      For i = 1 To CRLF
        DrawText(100, y, StringField(Drucke$, i, Chr(10)+Chr(13)))
        y + textHoehe
      Next i
      
      StopDrawing()
   
    EndIf
   
    StopPrinting()
  EndIf
EndIf
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
Carl
Beiträge: 15
Registriert: 28.10.2013 20:45
Computerausstattung: Windows 7 Professional / Windows 10

AMD FX(tm)-8320 Eight-Core Processor 3,5 Ghz
8 GB Speicher
PureBasic 5.62 (Windows - x64)

Re: String ausdrucken

Beitrag von Carl »

Danke für die schnelle Antwort, funktioniert super
Gruß Carl
Benutzeravatar
#NULL
Beiträge: 2235
Registriert: 20.04.2006 09:50

Re: String ausdrucken

Beitrag von #NULL »

CRLF ist im übrigen 13 10 (und nicht 10 13).
Du kannst auch StartVectorDrawing(PrinterVectorOutput()) und dann AddPathText() verwenden, das kann glaube ich auch mit Zeilenumbrüchen umgehen.
my pb stuff..
Bild..jedenfalls war das mal so.
Antworten