Announcement

Collapse
No announcement yet.

Drucken von Strings

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drucken von Strings

    Ich habe auf meinem Formular 10 TEdit-Komponenten. Vor dem Ausdruck soll geprüft werden, welche TEdit-Komponenten Text enthalten (mehrere Wörter). Beim Ausdruck dieser Strings sollen diese dann in einer Druckzeile (170 mm Länge) nacheinander getrennt durch Komma und Leerzeichen ausgedruckt werden. Wenn diese Druckzeile voll ist, sollen die nicht in die erste Zeile passenden Strings in die nächste Druckzeile (180 mm Länge) ebenfalls nacheinander getrennt durch Komma und Leerzeichen ausgedruckt werden. Hinter dem letzten String soll kein Komma sondern ein Leerzeichen und ein '*' stehen. Passen nicht alle Strings in die zwei Druckzeilen, soll eine Meldung ausgegeben werden. Wichtig ist beim Ausdruck, daß die Strings nicht getrennt werden.
    Es wäre schön, wenn mir jemand bei diesem Problem helfen könnte.

    Tom.

  • #2
    <html>

    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
    <title>Normale Seite ohne Titel</title>
    </head>

    <body bgcolor="#FFFFFF">

    <pre>Hallo Tom,</pre>

    <pre>folgendes sollte helfen:</pre>

    <pre><strong>procedure TForm1.Button1Click(Sender: TObject);
    var
    string_array: array[1..2] of string;
    i: integer;
    const
    breite_array: array[1..2] of integer = (1700,1800); </strong><font
    color="#FF0080"><strong>{Zeilenlänge in 1/10mm}</strong></font><strong>

    </strong><font color="#0000A0"><strong>function test(var s: string; s1: string): boolean;
    var
    temp: string;
    begin
    temp := '';
    result := true;
    if length(s1) = 0 then exit;
    if length(s) &gt; 0 then begin
    temp := s;
    if s1 &lt;&gt; ' *' then temp := temp + ', ';
    end;
    temp := temp + s1;
    if printer.Canvas.TextWidth(temp) &lt;= breite_array[i] then
    s := temp
    else begin
    inc(i);
    if i &gt; 2 then begin
    application.messagebox('Text ist zu lang','Fehler',mb_ok);
    printer.abort;
    result := false;
    exit;
    end;
    string_array[i] := s1;
    end;
    end;</strong></font><strong>

    begin
    string_array[1] := '';
    string_array[2] := '';
    i := 1;
    printer.begindoc;
    setmapmode(printer.canvas.handle, mm_lometric); </strong><font
    color="#FF0080"><strong>{setzt den Windows-Abbildungsmodus auf 0,1 mm}</strong></font><strong>
    if not(test(string_array[i], edit1.text)) then exit;
    if not(test(string_array[i], edit2.text)) then exit;
    if not(test(string_array[i], edit3.text)) then exit;
    if not(test(string_array[i], edit4.text)) then exit;
    if not(test(string_array[i], edit5.text)) then exit;
    if not(test(string_array[i], edit6.text)) then exit;
    if not(test(string_array[i], edit7.text)) then exit;
    if not(test(string_array[i], edit8.text)) then exit;
    if not(test(string_array[i], edit9.text)) then exit;
    if not(test(string_array[i], edit10.text)) then exit;
    if not(test(string_array[i], ' *')) then exit;
    if string_array[1] &lt;&gt; '' then printer.canvas.textout(0,0, string_array[1]);
    if string_array[2] &lt;&gt; '' then printer.Canvas.TextOut(0,20, string_array[2]);
    printer.abort;
    end;</strong></pre>

    Es geht mit Sicherheit auch eleganter (ist nur auf die Schnelle zusammengebastelt).

    <p>Tschüß

    <p>Torsten
    </body>
    </html&gt

    Comment


    • #3
      <html>

      <head>
      <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1">
      <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
      <title>Normale Seite ohne Titel</title>
      </head>

      <body bgcolor="#FFFFFF">

      <pre>Hallo Tom,</pre>

      <pre>folgendes sollte helfen:</pre>

      <pre><strong>procedure TForm1.Button1Click(Sender: TObject);
      var
      string_array: array[1..2] of string;
      i: integer;
      const
      breite_array: array[1..2] of integer = (1700,1800); </strong><font
      color="#FF0080"><strong>{Zeilenlänge in 1/10mm}</strong></font><strong>

      </strong><font color="#0000A0"><strong>function test(var s: string; s1: string): boolean;
      var
      temp: string;
      begin
      temp := '';
      result := true;
      if length(s1) = 0 then exit;
      if length(s) &gt; 0 then begin
      temp := s;
      if s1 &lt;&gt; ' *' then temp := temp + ', ';
      end;
      temp := temp + s1;
      if printer.Canvas.TextWidth(temp) &lt;= breite_array[i] then
      s := temp
      else begin
      inc(i);
      if i &gt; 2 then begin
      application.messagebox('Text ist zu lang','Fehler',mb_ok);
      printer.abort;
      result := false;
      exit;
      end;
      string_array[i] := s1;
      end;
      end;</strong></font><strong>

      begin
      string_array[1] := '';
      string_array[2] := '';
      i := 1;
      printer.begindoc;
      setmapmode(printer.canvas.handle, mm_lometric); </strong><font
      color="#FF0080"><strong>{setzt den Windows-Abbildungsmodus auf 0,1 mm}</strong></font><strong>
      if not(test(string_array[i], edit1.text)) then exit;
      if not(test(string_array[i], edit2.text)) then exit;
      if not(test(string_array[i], edit3.text)) then exit;
      if not(test(string_array[i], edit4.text)) then exit;
      if not(test(string_array[i], edit5.text)) then exit;
      if not(test(string_array[i], edit6.text)) then exit;
      if not(test(string_array[i], edit7.text)) then exit;
      if not(test(string_array[i], edit8.text)) then exit;
      if not(test(string_array[i], edit9.text)) then exit;
      if not(test(string_array[i], edit10.text)) then exit;
      if not(test(string_array[i], ' *')) then exit;
      if string_array[1] &lt;&gt; '' then printer.canvas.textout(0,0, string_array[1]);
      if string_array[2] &lt;&gt; '' then printer.Canvas.TextOut(0,20, string_array[2]);
      printer.abort;
      end;</strong></pre>

      <p><font face="Courier New">Es geht mit Sicherheit auch eleganter
      (ist nur auf die Schnelle zusammengebastelt). </font></p>

      <p><font face="Courier New">Tschüß </font></p>

      <p><font face="Courier New">Torsten </font></p>
      </body>
      </html&gt

      Comment


      • #4
        <html>

        <head>
        <meta http-equiv="Content-Type"
        content="text/html; charset=iso-8859-1">
        <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
        <title>Normale Seite ohne Titel</title>
        </head>

        <body bgcolor="#FFFFFF">

        <pre>Hallo Tom,</pre>

        <pre>folgendes sollte helfen:</pre>

        <pre>procedure TForm1.Button1Click(Sender: TObject);
        var
        string_array: array[1..2] of string;
        i: integer;
        const
        breite_array: array[1..2] of integer = (1700,1800); <font
        color="#FF0080">{Zeilenlänge in 1/10mm}</font>
        </pre>

        <pre>
        <font color="#0000A0">function test(var s: string; s1: string): boolean;
        var
        temp: string;
        begin
        temp := '';
        result := true;
        if length(s1) = 0 then exit;
        if length(s) &gt; 0 then begin
        temp := s;
        if s1 &lt;&gt; ' *' then temp := temp + ', ';
        end;
        temp := temp + s1;
        if printer.Canvas.TextWidth(temp) &lt;= breite_array[i] then
        s := temp
        else begin
        inc(i);
        if i &gt; 2 then begin
        application.messagebox('Text ist zu lang','Fehler',mb_ok);
        printer.abort;
        result := false;
        exit;
        end;
        string_array[i] := s1;
        end;
        end;
        </font></pre>

        <pre><font color="#0000A0">
        </font><font color="#400040">begin
        string_array[1] := '';
        string_array[2] := '';
        i := 1;
        printer.begindoc;
        setmapmode(printer.canvas.handle, mm_lometric);</font><font
        color="#0000A0"> </font><font color="#FF0080">{setzt den Windows-Abbildungsmodus auf 0,1 mm}</font>
        if not(test(string_array[i], edit1.text)) then exit;
        if not(test(string_array[i], edit2.text)) then exit;
        if not(test(string_array[i], edit3.text)) then exit;
        if not(test(string_array[i], edit4.text)) then exit;
        if not(test(string_array[i], edit5.text)) then exit;
        if not(test(string_array[i], edit6.text)) then exit;
        if not(test(string_array[i], edit7.text)) then exit;
        if not(test(string_array[i], edit8.text)) then exit;
        if not(test(string_array[i], edit9.text)) then exit;
        if not(test(string_array[i], edit10.text)) then exit;
        if not(test(string_array[i], ' *')) then exit;
        if string_array[1] &lt;&gt; '' then printer.canvas.textout(0,0, string_array[1]);
        if string_array[2] &lt;&gt; '' then printer.Canvas.TextOut(0,20, string_array[2]);
        printer.enddoc;
        end;</pre>

        <p><font face="Courier New">Es geht mit Sicherheit auch eleganter
        (ist nur auf die Schnelle zusammengebastelt). </font></p>

        <p><font face="Courier New">Tschüß </font></p>

        <p><font face="Courier New">Torsten </font></p>
        </body>
        </html&gt

        Comment

        Working...
        X