Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: a Unit problem?
« Last post by EventHorizon on Today at 01:52:28 pm »
and the compilation failed  :P :-[
And by withholding  the error message you think someone is able to help you ? My car won't start someone please help me while you could just as well have turned the key in the ignition ?  :P
Apparently you are hasty as I, but you saw were I was drawn to. So, be careful  :P
2
General / Re: a Unit problem?
« Last post by EventHorizon on Today at 01:51:21 pm »
Please, accept my apologies. Indeed, I made I mistake and you saw the message before withdrawing it.

Sorry again, and thank you for your help.
3
Try to see what error you get with this:
Code: Pascal  [Select][+][-]
  1. ShowMessage(E.Message);
4
Windows (32/64) / Re: Complex package installation problem
« Last post by parcel on Today at 01:48:04 pm »
5
General / Re: a Unit problem?
« Last post by TRon on Today at 01:45:04 pm »
and the compilation failed  :P :-[
And by withholding  the error message you think someone is able to help you ? My car won't start someone please help me while you could just as well have turned the key in the ignition ?  :P

@Thaddy:
Probably a linker error  ;D

Code: [Select]
$> fpc -B mandelbrot.lpr -dUseCThreads
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling mandelbrot.lpr
Linking mandelbrot
/usr/bin/ld: cannot find -lXxf86dga: No such file or directory
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /home/apps/fpc/3.2.2/bin/x86_64-linux/ppcx64 returned an error exitcode
6
General / Re: a Unit problem?
« Last post by Thaddy on Today at 01:42:22 pm »
You must have done more since this compiles and works guaranteed;
Code: Pascal  [Select][+][-]
  1. {******************}
  2. {* Mandelbrot Set *}
  3. {******************}
  4.  
  5. program mandelbrot;
  6.  
  7. {$mode objfpc}{$H+}
  8.  
  9. uses
  10.   {$IFDEF UNIX}
  11.   cthreads,
  12.   {$ENDIF}
  13.   Classes,
  14.   sysutils, ptccrt, ptcgraph;
  15.  
  16. const
  17.   XSMax   = 800;                                                               // screen width
  18.   YSMax   = 600;                                                               // screen height
  19.   NColors = 256;                                                               // number of colors
  20.  
  21. var
  22.   XS, YS, YSH, Iter, NIters, XYColor, Error: Integer;
  23.   GD, GM: SmallInt;
  24.   X, Y, X0, Y0, XScaleLow, XScaleHigh, XScale0, Zoom, XYZoom, T: Real;
  25.   S: string;
  26.  
  27. begin
  28.   repeat
  29.     ClrScr;
  30.     TextColor(Yellow);
  31.     Writeln('Mandelbrot Set');
  32.     Writeln('==============');
  33.     Writeln;
  34.     TextColor(LightGray);
  35.     XScaleLow := -2.5; XScaleHigh := 1;                                        // Mandelbrot set X scale
  36.     Writeln('For Help with this program, please look at the');
  37.     Writeln('ReadMe file included with the .zip archive...'); Writeln;
  38.     Writeln('Mandelbrot set X scale = ', XScaleLow:0:2, ' to ', XScaleHigh:0:2);
  39.     Writeln('To "shift" the graphics leftwards, enter X > ', XScaleLow:0:2); Writeln();
  40.     // Number of iterations (determines graphics details and colors)
  41.     repeat
  42.       Write ('Number of iterations (default = 256; 0 to quit) ? '); Readln(S);
  43.       if S = '' then
  44.         NIters := NColors
  45.       else
  46.         NIters := StrToInt(S);
  47.     until (NIters = 0) or (NIters >= 16);
  48.     if NIters > 0 then begin
  49.       // Graphics zoom factor
  50.       repeat
  51.         Write('Zoom (or ENTER for default = 1)                 ? '); Readln(S);
  52.         if S = '' then
  53.           Zoom := 1
  54.         else
  55.           Zoom := StrToFloat(S);
  56.       until (Zoom >= 1);
  57.       XYZoom := (YSMax / 3) * Zoom;                                            // (YSMax / 3) * 1 centers the full Mandelbrot set in the graphics window
  58.       // Starting X value within the Mandelbrot set scale
  59.       repeat
  60.         Write('X scale value (or ENTER for default = -2.5)     ? '); Readln(S);
  61.         if S = '' then
  62.           XScale0 := XScaleLow
  63.         else
  64.           XScale0 := StrToFloat(S);
  65.       until (XScale0 >= XScaleLow -(XScaleHigh - XScaleLow)) and (XScale0 <= XScaleHigh);
  66.       Writeln; Write('Hit ENTER to continue... ');
  67.       // Init graphics driver
  68.       GM := m800x600; GD := D8bit;                                             // 800 x 600 pixles, 256 colors
  69.       InitGraph(GD, GM, '');                                                   // graph initialization: this opens Graphics output window
  70.       // Check if selected graphics mode is supported
  71.       Error := GraphResult;
  72.       if (Error <> grOk) then begin
  73.         Writeln; Writeln; Writeln ('Graphics error: 640x480x256 graphics mode not supported!');
  74.         Readln;
  75.         Halt (1);
  76.       end;
  77.       // Mandelbrot set in 800x600x256 graphics mode
  78.       YSH := YSMax div 2;                                                      // vertical window center
  79.       for YS := 0 to YSH - 1 do begin
  80.         // For each half (as graphics is symetric) graphics window pixel Y-value
  81.         Y0 := YS / XYZoom;                                                     // Y-value scaled to Mandelbrot set
  82.         for XS := 0 to XSMax - 1 do begin
  83.           // For each graphics window pixel X-value
  84.           X0 := XS / XYZoom + XScale0;                                         // X-value scaled to Mandelbrot set
  85.           X := X0; Y := Y0; Iter := 0;                                         // initial X/Y-values
  86.           // Iterate = calculate next value of (complex numbers) series...
  87.           repeat
  88.             T := X;
  89.             X := Sqr(X) - Sqr(Y) + X0;                                         // new X-value
  90.             Y := 2 * T * Y + Y0;                                               // new Y-value
  91.             Inc(Iter);
  92.           // ... until the series diverges or the (chosen) maximum of iterations is reached
  93.           until (Sqr(X) + Sqr(Y) > 4) or (Iter = NIters);
  94.           XYColor := Iter mod NColors;                                         // pixel color depending on number of iterations done
  95.           PutPixel(XS, YSH - YS, XYColor);                                     // display the pixel in upper half graphics window
  96.           PutPixel(XS, YSH + YS, XYColor);                                     // display the pixel in lower half graphics window
  97.         end;
  98.       end;
  99.       // Return to text mode
  100.       Readln;
  101.       CloseGraph;
  102.     end;
  103.   until (NIters = 0);
  104. end.
7
Win 10, Laz 3.2
I have a project that creates a pdf from a form and sends that form as an attachment to an email.
It compiles and runs but fails to send the email.
If I set the cursor on the call to create the email and use run to cursor, it creates the email and sends it successfully when I use f7 or f8 to continue from that point.
I have installed the latest Lazarus.
I compiled the ide with the needed packages. Synapse4.
It uses x-mailer, smtpsend and openssl-09.8d
It is odd that it works when I step through it and fails when I executes from the run command.
On failure it gives me the E:Exception message.

Code: Pascal  [Select][+][-]
  1. procedure TestXM(Subject,fname:String;Var Result:Boolean);
  2.  
  3. var
  4.   Form5: TForm5;
  5.  
  6. implementation
  7.  
  8. {$R *.lfm}
  9. procedure TestXM(Subject,fname:String;Var Result:Boolean);
  10. var
  11.   Mail: TSendMail;
  12. begin
  13.   Mail := TSendMail.Create;
  14.   form5:=Tform5.Create(Nil);
  15.   Form5.Show;
  16.   Form5.Memo1.Clear;
  17.   Form5.Memo1.Append('Building Email ....');
  18. try
  19.     Mail.Sender := dfr.SmtpMailfrom;//dfr.Store+'Shiftinfo@no.net';   // Show up as sender
  20.     Mail.Receivers.Add(dfr.SmtpMailto); //('################');
  21.     If dfr.cc1 >'' then
  22.       Mail.Receivers.Add(dfr.cc1);
  23.     If dfr.cc2 >'' then
  24.       Mail.Receivers.Add(dfr.cc2);
  25.     Mail.Subject := Subject; //'Test pdf file attached';
  26.     Mail.Message.Add('Shiftwork');
  27.     // SMTP
  28.     Mail.Smtp.UserName :=dfr.smtpU;  //'1test@######.com';
  29.     Mail.Smtp.Password := dfr.SmtpPass; //##########;
  30.     Mail.Smtp.Host := dfr.SmtpS; //'mail.######.com';
  31.     Mail.Smtp.Port := Trim(dfr.SmtpP);
  32.     If Mail.Smtp.Port ='465' then
  33.     begin
  34.       Mail.Smtp.SSL := True;
  35.       Mail.Smtp.FullSSL:=true;
  36.       Mail.Smtp.TLS:=False;
  37.     end
  38.     else
  39.      begin
  40.        Mail.Smtp.SSL := True;
  41.        Mail.Smtp.FullSSL:=False;
  42.        Mail.Smtp.TLS:=True;
  43.      end;
  44.      Form5.Memo1.Append('Adding Attachment ....');
  45.      Mail.Attachments.Add(fname);      // add attachment
  46.  
  47.     Mail.Send;
  48.     Result:=True;
  49.     Windows.beep(1000,300);
  50.    Form5.Memo1.Append('Email send is successful!');
  51.     Windows.beep(1000,300);
  52.   except
  53.     on E:Exception do
  54.     begin
  55.       Windows.beep(100,300);
  56.       Form5.Memo1.Append('Email send FAILURE!');
  57.       Showmessage('Email failed');
  58.       Windows.beep(100,300);
  59.     end;
  60.   end;
  61.   Mail.free;
  62.   Form5.free;
  63.  end;      
8
General / Re: a Unit problem?
« Last post by EventHorizon on Today at 01:29:59 pm »
change:
uses graph;
to uses ptcgraph;

ptcgraph is compatible with graph and often works a bit better on linux.
should not require any other code changes.
[edit] changed uses like so:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2. uses
  3.   {$IFDEF UNIX}
  4.   cthreads,
  5.   {$ENDIF}
  6.   Classes,
  7.   sysutils, ptccrt, ptcgraph;
tested linux64 debian bookworm and windows11-64. No other code changes.

First I simply did ptcgraph substitution. Compilation succeeded but program crashed:
Code: Text  [Select][+][-]
  1. ]
  2. ./mandelbrot                                                                                                                                            ─╯
  3. Threading has been used before cthreads was initialized.
  4. Make cthreads one of the first units in your uses clause.
  5. Runtime error 211 at $00000000004EA38D
  6.                                         $00000000004EA38D
  7.                                                            $0000000000425FCC
  8.  

Then, I did what you quote:
Code: Pascal  [Select][+][-]
  1.     {$mode objfpc}{$H+}
  2.     uses
  3.       {$IFDEF UNIX}
  4.       cthreads,
  5.       {$ENDIF}
  6.       Classes,
  7.       sysutils, ptccrt, ptcgraph;
  8.  
and the compilation failed  :P :-[
9
General / Re: a Unit problem?
« Last post by TRon on Today at 01:15:56 pm »
But what TRon said: I looked at the link TS provided, and there is indeed an LPI-File in that zip
And indeed the matter is a bit more complicated. There does not seem to exist a unit graph for Linux X86_64 bit. The mandelbrot project project does seem to be a "simple" console project.

change:
uses grapch;
to uses ptcgraph;
So... try with Thaddy's  suggestion.
10
General / Re: a Unit problem?
« Last post by Thaddy on Today at 01:10:07 pm »
change:
uses graph;
to uses ptcgraph;

ptcgraph is compatible with graph and often works a bit better on linux.
should not require any other code changes.
[edit] changed uses like so:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2. uses
  3.   {$IFDEF UNIX}
  4.   cthreads,
  5.   {$ENDIF}
  6.   Classes,
  7.   sysutils, ptccrt, ptcgraph;
tested linux64 debian bookworm and windows11-64. No other code changes.
Note as you can see, I also changed the cthreads define a bit, because you must always use cthreads since ptc is multithreaded.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018