Recent

Recent Posts

Pages: 1 ... 8 9 [10]
91
General / Re: sending email not working
« Last post by Fibonacci on June 12, 2024, 08:30:30 pm »
I guess you should run "msmtp", not "echo", and then send there your text with pipes
92
General / Re: sending email not working
« Last post by TRon on June 12, 2024, 08:24:51 pm »
Can someone tell me what is wrong with the above PASCAL CODE?
TProcess is not a shell replacement.
93
General / sending email not working
« Last post by Awesome Programmer on June 12, 2024, 08:21:04 pm »
my Lazarus compiler 2.0.0. Yes, Yes... I know it is sooooo old that I shouldn't use this version at all... lol... but it is working and compiling my code with NO ISSUES whatsoever. If I were to upgrade, it will break over 50% of all my components and LIBRARIES that means many of my codes/program will seize to compile forever. Just thought I'd let you all know, before you all jump on me for this... lol...  :D

Anyways, I am trying to use the msmtp terminal command to send email messages. I have searched online for this command and found a lot of good information and samples. So, I was able to come up with a  command line that works flawlessly. It sends email and I can even send SMS text message to smartphone. ONLY through TERMINAL or CONSOLE.

Code: Pascal  [Select][+][-]
  1. echo "Hello world" | msmtp --from=James@James.com 1234567899@tmomail.net

However, this same commandline code WILL NOT execute from within Lazarus. No message box pops up or gives any hints or errors. I don't get SMS or EMAIL message either. The function is below.

Code: Pascal  [Select][+][-]
  1. function SendMail:Boolean;
  2. var
  3.  sp:TProcess;
  4.  L:Tstringlist;
  5. begin
  6.   l:=tstringlist.create;
  7.     sp:= Tprocess.Create(nil);
  8.     try
  9.       sp.options:=[poUsePipes];
  10.       sp.executable := 'echo';
  11.       sp.Parameters.Add('"Hello World"');
  12.       sp.Parameters.Add('|');
  13.       sp.Parameters.Add('msmpt --from=james@james.com 1234567899@tmomail.net');
  14.       sp.execute;
  15.       l.SaveToStream(sp.Input);
  16.       l.clear;
  17.       l.LoadfromStream(sp.output);
  18.       writeln(l.text);
  19.     finally
  20.       sp.free;
  21.       l.free;
  22.     end;
  23.     result:=true;
  24. end;

Can someone tell me what is wrong with the above PASCAL CODE?
94
General / Re: Heap overflow error in GetControlText after TMemo.Lines.LoadFromFile
« Last post by af0815 on June 12, 2024, 08:20:48 pm »
My first idea was - why is someone putting such an amount of data in a visual control ? I see no effort to do this. No person can work with this. 450.000 Lines in a visual control. It looks for me like da misdesigned user interface. Or did i miss something.

 
95
First of all.

Code: Pascal  [Select][+][-]
  1. while not SQLQuery.EOF and (SQLQuery.FieldByName('session_id').AsInteger = SessionID) do

The check for session_id isn't needed because you have a SQL where you only ask for records with that session_id. So you shouldn't get any other. That check is useless.

Second, sometimes the debugger can jump back to the beginning of the procedure when it is at the end. I think it has something to do with the cleanup. If you press f8 again (step through) you should jump to the end again. The procedure won't repeat itself (unless the calling functions calls it again).
96
Other / Re: Building Lazarus 3.4 with FreePascal 3.2.2 fails under OpenBSD 7.5
« Last post by TCH on June 12, 2024, 07:35:36 pm »
I see. Good to know, thanks.

In the meantime i tried to check if Lazarus needs GTK or not: objdump -x startlazarus | grep ' NEEDED '
Code: [Select]
  NEEDED      libiconv.so.7.1
  NEEDED      libpthread.so.27.1
  NEEDED      libgdk-x11-2.0.so.2400.0
  NEEDED      libgtk-x11-2.0.so.2400.0
  NEEDED      libX11.so.18.0
  NEEDED      libgdk_pixbuf-2.0.so.3200.3
  NEEDED      libgobject-2.0.so.4200.18
  NEEDED      libglib-2.0.so.4201.11
  NEEDED      libgthread-2.0.so.4200.18
  NEEDED      libgmodule-2.0.so.4200.18
  NEEDED      libpango-1.0.so.3801.4
  NEEDED      libcairo.so.13.4
  NEEDED      libatk-1.0.so.21810.1
  NEEDED      libc.so.99.0
objdump -x lazarus | grep ' NEEDED '
Code: [Select]
  NEEDED      libpthread.so.27.1
  NEEDED      libiconv.so.7.1
  NEEDED      libgdk-x11-2.0.so.2400.0
  NEEDED      libgtk-x11-2.0.so.2400.0
  NEEDED      libX11.so.18.0
  NEEDED      libgdk_pixbuf-2.0.so.3200.3
  NEEDED      libgobject-2.0.so.4200.18
  NEEDED      libglib-2.0.so.4201.11
  NEEDED      libgthread-2.0.so.4200.18
  NEEDED      libgmodule-2.0.so.4200.18
  NEEDED      libpango-1.0.so.3801.4
  NEEDED      libcairo.so.13.4
  NEEDED      libatk-1.0.so.21810.1
  NEEDED      libpangocairo-1.0.so.3801.3
  NEEDED      libc.so.99.0
Neither gtk3, nor harfbuzz. So the problem might be between pango and harfbuzz, or gtk2 and harfbuzz and not even in Lazarus.
97
General / Re: Change button background color
« Last post by dodgebros on June 12, 2024, 07:29:09 pm »
thank you cdbc
TD
98
BGRABitmap and LazPaint / Re: Need help with phong
« Last post by bobby100 on June 12, 2024, 07:25:01 pm »
Remember TLCDDisplay that I and wp created (now part of the Industrial package)?
https://forum.lazarus.freepascal.org/index.php/topic,58357.0.html

TLCDDisplay (left part of the screenshot) is getting a younger brother - TBLCDDisplay (right part of the screenshot)
99
Other / Re: Building Lazarus 3.4 with FreePascal 3.2.2 fails under OpenBSD 7.5
« Last post by marcov on June 12, 2024, 07:19:29 pm »
I see. So, it is unlikely, that 3.2.4, or even 3.4.0 will fix these problems.

Well, "these problems" is vague, but the change rate of OpenBSD is glacial atm, and depends on random external contributions.

It was effectively dead, when some guy submitted some patches to turn it into a libc port. But I haven't seen new patches in a while.

Like FreeBSD, the LLVM changes might have an profound impact, as the LLVM binaries are less suitable (read: stable outside the very narrow area stressed by the corresponding C compiler) than the GCC ones.

Even on FreeBSD, we still use ld.bfd.
100
I will preface this post with the acknowledgement that this problem may not have anything to do with SQLQuery, but I can't track down the problem; hence the post for help.

I am attempting to retrieve data from an SQLite3 database and loading the data into some other List variables for display massaging before the actual display on the form.

For some reason my looping through the messages table causes a jump out of the loop to the beginning of the procedure.

Here is my procedure:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.BtnLoadClick(Sender: TObject);
  2. var
  3.   SelectedIndex, SessionID, i, j: Integer;
  4.   QA: TQandA;
  5.   Role, Content: string;
  6. begin
  7.   try
  8.     SelectedIndex := Subjects.ItemIndex;
  9.  
  10.     // Retrieve the session ID from the selected item
  11.     SessionID := PtrInt(Subjects.Items.Objects[SelectedIndex]);
  12.  
  13.     // Query the database for the session details
  14.     SQLQuery.Close; // Ensure SQLQuery is closed before setting new SQL text
  15.     SQLQuery.SQL.Text := 'SELECT * FROM sessions WHERE id = :id';
  16.     SQLQuery.Params.ParamByName('id').AsInteger := SessionID;
  17.     SQLQuery.Open;
  18.  
  19.     if SQLQuery.RecordCount = 0 then
  20.     begin
  21.       ShowMessage('Session not found.');
  22.       SQLQuery.Close;
  23.       Exit;
  24.     end;
  25.  
  26.     // Assign the session ID to CurrentSessionID
  27.     CurrentSessionID := SessionID;
  28.  
  29.     // Load session details into variables
  30.     temperature := SQLQuery.FieldByName('temperature').AsFloat;
  31.     presence_penalty := SQLQuery.FieldByName('presence_penalty').AsFloat;
  32.     frequency_penalty := SQLQuery.FieldByName('frequency_penalty').AsFloat;
  33.     max_tokens := SQLQuery.FieldByName('max_tokens').AsInteger;
  34.     max_Query := SQLQuery.FieldByName('max_tokens_query').AsInteger;
  35.     top_p := SQLQuery.FieldByName('top_p').AsFloat;
  36.     SYSTEM_MSG := SQLQuery.FieldByName('system_msg').AsString;
  37.     image_mode := SQLQuery.FieldByName('is_image_mode').AsBoolean;
  38.     assistant_id := SQLQuery.FieldByName('tool_choice').AsString;
  39.  
  40.     // Load the messages for the session
  41.     SQLQuery.Close;
  42.     SQLQuery.SQL.Text := 'SELECT * FROM messages WHERE session_id = :session_id ORDER BY id';
  43.     SQLQuery.Params.ParamByName('session_id').AsInteger := SessionID;
  44.     SQLQuery.Open;
  45.  
  46.     QA := TQandA.Create;
  47.  
  48.     try
  49.       while not SQLQuery.EOF and (SQLQuery.FieldByName('session_id').AsInteger = SessionID) do
  50.       begin
  51.         Role := SQLQuery.FieldByName('role').AsString;
  52.         Content := SQLQuery.FieldByName('content').AsString;
  53.  
  54.         if Role = 'user' then
  55.           QA.Question.Add(Content)
  56.         else if Role = 'assistant' then
  57.           QA.Response.Add(Content);
  58.  
  59.         SQLQuery.Next;   // <-- This statement jumps back to line 8 for some reason.
  60.       end;
  61.     except
  62.       on E: Exception do
  63.       begin
  64.         ShowMessage('Error processing messages: ' + E.Message);
  65.         QA.Free;
  66.         Exit;
  67.       end;
  68.     end;
  69.  
  70.     // Add the QA object to the Conversation
  71.     Conversation.Add(QA);   // Variable of type TConversationList = specialize TFPGObjectList<TQandA>;
  72.  
  73.     SQLQuery.Close;
  74.  
  75.   except
  76.     on E: Exception do
  77.       ShowMessage('Error loading session: ' + E.Message);
  78.   end;
  79. end;  

The important line is 59 where SQLQuery.Next is called.  I have stepped through the code and when this line executes it jumps to line 8 and I cannot figure out why.

The above procedure (BtnLoadClick) is called after this procedure:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.LoadSubjects;
  2. var
  3.   SessionID: PtrInt;
  4. begin
  5.   try
  6.     SQLQuery.SQL.Text := 'SELECT id, title FROM sessions';
  7.     SQLQuery.Open;
  8.  
  9.     Subjects.Items.Clear;
  10.  
  11.     if SQLQuery.RecordCount <> 0 then
  12.       while not SQLQuery.EOF do
  13.       begin
  14.         SessionID := SQLQuery.FieldByName('id').AsInteger;
  15.         Subjects.Items.AddObject(SQLQuery.FieldByName('title').AsString,
  16.                                  TObject(SessionID));
  17.         SQLQuery.Next;
  18.       end;
  19.  
  20.     SQLQuery.Close;
  21.   except
  22.     on E: Exception do
  23.       ShowMessage('Error loading sessions: ' + E.Message);
  24.   end;
  25. end;      

Which executes properly.  There are some variable assignments in between the two calls, but nothing relating to these two procedures.

Debugging tips welcome.
Pages: 1 ... 8 9 [10]

TinyPortal © 2005-2018