Recent

Author Topic: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?  (Read 2094 times)

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« on: January 10, 2025, 03:13:16 am »
How do I get the following Units?  I put these in the uses section and the compiler message is "Project.lpr(4,3) Fatal: Cannot find IdHTTP used by GetPrices of the Project Inspector".  And the same message for the other 3.

  IdHTTP,  IdSSL,  IdGlobal  and  IdSSLOpenSSL.

I fist thought it would be in the "Online Package Manager".  But there doesn't seem to be a search box and none of the packages start with "Id".
So then I clicked on "Install/uninstall packages" and saw these:

idefilebrowser 0.2,  ideinspectop 0.1,  idelazlogger 1.0  and  idescout 0.0.1.

Do any of these packages have the above units?

If not, where do I get these units and how do I install them?

Thanks for any help y'all can give.
« Last Edit: January 10, 2025, 08:58:42 am by OC DelGuy »
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

dsiders

  • Hero Member
  • *****
  • Posts: 1321
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #1 on: January 10, 2025, 03:45:02 am »
How do I get the following Units?  I put these in the uses section and the compiler message is "Project.lpr(4,3) Fatal: Cannot find IdHTTP used by GetPrices of the Project Inspector".  And the same message for the other 3.

  IdHTTP,  IdSSL,  IdGlobal  and  IdSSLOpenSSL.

I fist thought it would be in the "Online Package Manager".  But there doesn't seem to be a search box and none of the packages start with "Id".
So then I clicked on "Install/uninstall packages" and saw these:

idefilebrowser 0.2,  ideinspectop 0.1,  idelazlogger 1.0  and  idescout 0.0.1.

Do any of these packages have the above units?

If not, where do I get these units and how do I install them?

Thanks for any help y'all can give.

Those files are part of the Indy package, and available on OPM.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #2 on: January 10, 2025, 04:26:13 am »
Ok, So I installed it from the Online Package Manager.  It automatically recompiled the IDE.

Still same Message: "Project.lpr(4,3) Fatal: Cannot find IdHTTP used by GetPrices of the Project Inspector"

Did I miss something?
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

dsiders

  • Hero Member
  • *****
  • Posts: 1321
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #3 on: January 10, 2025, 06:42:39 am »
Ok, So I installed it from the Online Package Manager.  It automatically recompiled the IDE.

Still same Message: "Project.lpr(4,3) Fatal: Cannot find IdHTTP used by GetPrices of the Project Inspector"

Did I miss something?

Look at the Project Inspector and make sure the project has a dependency on the Indy package. Or, post the .lpr file so we can see what it's doing.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #4 on: January 10, 2025, 08:43:34 am »
How's this?
Code: Pascal  [Select][+][-]
  1. program Project;
  2.  
  3. uses
  4.   IdHTTP,
  5.   IdSSL,
  6.   IdGlobal,
  7.   IdSSLOpenSSL,
  8.   StrUtils;
  9.  
  10. const
  11.   API_URL = 'https://www.  API key goes here.   ';     // Sorry, I had to delete the API Website and Key.
  12.  
  13. var
  14.   HTTP: TIdHTTP;
  15.   XMLDoc: IXMLDocument;
  16.   PriceNode: IXMLNode;
  17.   SilverAsk: Double;
  18.   SilverBid: Double;
  19.   GoldAsk: Double;
  20.   GoldBid: Double;
  21.   S: String;
  22. begin
  23.   HTTP := TIdHTTP.Create(nil);
  24.   try
  25.     HTTP.HandleRedirects := True;
  26.     HTTP.ReadTimeout := 10000; // 10 seconds
  27.     HTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
  28.  
  29.     XMLDoc := TXMLDocument.Create(nil);
  30.     try
  31.       S := HTTP.Get(API_URL);
  32.       XMLDoc.LoadFromXML(S);
  33.  
  34.       SilverAsk := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[2].ChildNodes[2].Text);
  35.       SilverBid := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[3].ChildNodes[2].Text);
  36.       GoldAsk := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[5].ChildNodes[2].Text);
  37.       GoldBid := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[6].ChildNodes[2].Text);
  38.  
  39.       WriteLn('Silver Ask: ', SilverAsk);
  40.       WriteLn('Silver Bid: ', SilverBid);
  41.       WriteLn('Gold Ask: ', GoldAsk);
  42.       WriteLn('Gold Bid: ', GoldBid);
  43.  
  44.     finally
  45.       XMLDoc.Free;
  46.     end;
  47.   finally
  48.     HTTP.Free;
  49.   end;
  50.   ReadLn;
  51. end.    
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

cdbc

  • Hero Member
  • *****
  • Posts: 1746
    • http://www.cdbc.dk
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #5 on: January 10, 2025, 10:28:05 am »
Hi
Try this:
In the 'Project Inspector', click [Add] -> 'New Requirement'
Then scroll down in the list till you see 'Indy' and click that.
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #6 on: January 10, 2025, 04:11:31 pm »
Well, the good news is:  It now recognizes the units! :) :D
The bad news is: It now balks at the Data Types!  :(  ::)

Is there an XML unit?  Most of the error lines have that in common.
And it's having a hissy fit with the StrToFloat Function.  Is that function in a unit that I didn't include in the uses section?
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6639
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #7 on: January 10, 2025, 04:47:13 pm »
Is there an XML unit?  Most of the error lines have that in common.
And it's having a hissy fit with the StrToFloat Function.  Is that function in a unit that I didn't include in the uses section?
You should be able to find ALL that with a simple Google search.

https://www.freepascal.org/docs-html/rtl/sysutils/strtofloat.html
https://wiki.freepascal.org/XML_Tutorial

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #8 on: January 10, 2025, 09:49:05 pm »
You should be able to find ALL that with a simple Google search.

Yes, You are quite correct, rvk.  I just got caught up in the back and forth of posting on the forum.   :(

I've narrowed it down from 12 errors to just 5, which are technically just 2.  Four are the same error repeated.  See my compiler messages below.
So I searched for "LoadFromXML".  Unfortunately I did not understand most of what was returned.
The (I will call it) "Text" error, So I thought "Text" might not be right.   So I tried "Caption" (just for the heck of it) and it didn't work either.
If anyone has solutions to these errors, Help!  :)


BTW, here's my uses code now:
Code: Pascal  [Select][+][-]
  1. uses
  2.   SysUtils,
  3.   IdHTTP,
  4.   IdSSL,
  5.   IdGlobal,
  6.   IdSSLOpenSSL,
  7.   StrUtils,
  8.   indylaz,
  9.   laz2_XMLRead,
  10.   laz2_DOM;
  11.  
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6639
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #9 on: January 10, 2025, 10:00:49 pm »
Where did you get the code from???

And isn't it TXMLDocument.LoadFromFile?

Otherwise there is ReadXMLFile and WriteXMLFile.
Those are standalone function, not class functions.

See https://wiki.lazarus.freepascal.org/XML_Tutorial

Also show the relevant lines that produce those error.

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #10 on: January 11, 2025, 03:13:49 am »
Where did you get the code from???
From the same company I got the API Key.  While VERY POLITE, They basically said: Hey, you're lucky we provided you that (code), fix it yourself!   >:(

And isn't it TXMLDocument.LoadFromFile?
Yes, I caught that on my own!  Sometimes I surprise myself!  :o   :D
I changed the "I" to a "T" and the error disappeared.   8-)

Otherwise there is ReadXMLFile and WriteXMLFile.
Those are standalone function, not class functions.
Now, this is something I noticed too.  All searches to try and download XML also mentioned XMLFile.  I'm under the impression that I'm downloading a stream and not a file.  Albeit a very short one (all of 6 digits a dollar sign and a decimal).  I may have my definitions wrong, but I think it supposed to be a stream because it changes all the time, I keep asking for the same information (What's the new price?  What's the new price?  What's the new price?  What's the new price?  What's the new price?) and it keeps sending the current price, as opposed to a file which is created (by them) and we download it once.  Am I wrong about this?

See https://wiki.lazarus.freepascal.org/XML_Tutorial
This is the link I read.  My take away: "What??"  The tutorial is way above my INT score!   :(

Also show the relevant lines that produce those error.

The lines are posted in one of the replies above.  But here they are again.  All five errors.  It's easy enough to list them again.  Just hope the mods don't scold me for reposting the same stuff.
Code: Pascal  [Select][+][-]
  1.       XMLDoc.LoadFromXML(S);
  2.  
  3.       SilverAsk := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[2].ChildNodes[2].Text);
  4.       SilverBid := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[3].ChildNodes[2].Text);
  5.       GoldAsk := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[5].ChildNodes[2].Text);
  6.       GoldBid := StrToFloat(XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[6].ChildNodes[2].Text);
  7.  
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1447
    • Lebeau Software
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #11 on: January 11, 2025, 04:28:46 am »
I'm under the impression that I'm downloading a stream and not a file.

Neither, actually. The server has no concept of either. You are sending a request, and it is sending a response. Nothing more. How your client uses that response is not the server's concern.

I may have my definitions wrong, but I think it supposed to be a stream because it changes all the time, I keep asking for the same information (What's the new price?  What's the new price?  What's the new price?  What's the new price?  What's the new price?) and it keeps sending the current price, as opposed to a file which is created (by them) and we download it once.  Am I wrong about this?

You can certainly download the XML data into a stream, and then load the XMLDocument from that stream. Or, you can download the XML data as a String, and then load the XMLDocument from that String. You have options available.  But they do not require you to save and load a file locally.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

rvk

  • Hero Member
  • *****
  • Posts: 6639
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #12 on: January 11, 2025, 02:47:18 pm »
Where did you get the code from???
From the same company I got the API Key.  While VERY POLITE, They basically said: Hey, you're lucky we provided you that (code), fix it yourself!   >:(
I thought it maybe came from ChatGPT  :D

I'm under the impression that I'm downloading a stream and not a file.  Albeit a very short one (all of 6 digits a dollar sign and a decimal).  I may have my definitions wrong, but I think it supposed to be a stream because it changes all the time, I keep asking for the same information (What's the new price?  What's the new price?  What's the new price?  What's the new price?  What's the new price?) and it keeps sending the current price, as opposed to a file which is created (by them) and we download it once.  Am I wrong about this?
You might want to take a step back.
DON'T try to load a string which you download directly into XMLDoc unless you are sure it is really XML data.

You haven't said anything about what service and how to use it.
For now, it's then best to just do a Showmessage(S) or Memo1.Lines.Text := S so you can see what's actually returned.
If you get the expected results... then you try to read it into XMLDoc.

Also show the relevant lines that produce those error.
The lines are posted in one of the replies above.  But here they are again.  All five errors.  It's easy enough to list them again.  Just hope the mods don't scold me for reposting the same stuff.
I didn't see anything about "Caption" there in those lines ?????  %)

Next you do something like: XMLDoc.DocumentElement.ChildNodes[1].ChildNodes[2].ChildNodes[2]
Even in Delphi this would be bad programming because you don't know if the children are there (and how many).
So you could end up trying to access .Text from a NULL pointer.

It's best, when dealing with an XML, to do this element by element.
And only if you are sure the element you get is the correct one (and not null), go a step further.

But... finally... about the IXMLDocument... I think you got examples for Delphi. FPC doesn't have IXMLDocument and implements a completly different XML reading component.
So you need to let go of those lines for reading the XML, read the tutorials, and reprogram everything in your code relating to XML because the TDOMNode in FPC/laz2_DOM doesn't have .text as property, that's only in IXMLNode.

It does have TDOMNode.TextContent but you better read the tutorials first.
(for example section https://wiki.lazarus.freepascal.org/XML_Tutorial#Reading_a_text_node).


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11980
  • FPC developer.
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #13 on: January 11, 2025, 05:55:29 pm »
(It looks like Delphi XML code which are interfaces to Microsoft MSXML library afaik)

OC DelGuy

  • Full Member
  • ***
  • Posts: 144
Re: Where do I get IdHTTP, IdSSL, IdGlobal and IdSSLOpenSSL Units?
« Reply #14 on: January 12, 2025, 01:23:46 am »
OK, let me start over.

Here's my code:

Code: Pascal  [Select][+][-]
  1. program Project;
  2.  
  3. uses
  4.   laz2_DOM,
  5.   laz2_XMLRead,
  6.   StrUtils,
  7.   IdSSLOpenSSL,
  8.   IdGlobal,
  9.   IdSSL,
  10.   IdHTTP,
  11.   SysUtils;
  12.  
  13.  
  14.  
  15. const
  16.   API_URL = 'https://www.';     // Sorry, I had to delete the API Website and Key.
  17.  
  18. var
  19.   S: String;
  20.   HTTP: TIdHTTP;
  21.   XMLDoc: TXMLDocument;
  22.  
  23. begin
  24.   HTTP := TIdHTTP.Create(nil);
  25.   try
  26.     HTTP.HandleRedirects := True;
  27.     HTTP.ReadTimeout := 10000; // 10 seconds
  28.     HTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
  29.     XMLDoc := TXMLDocument.Create();
  30.     try
  31.       S := HTTP.Get(API_URL);
  32.       WriteLn(S);
  33.     finally
  34.       XMLDoc.Free;
  35.     end;
  36.   finally
  37.     HTTP.Free;
  38.   end;
  39.   ReadLn;
  40. end.

You'll notice I deleted a bunch of crap they (the API provider) sent me.  This compiles fine with no errors.  But when I run it, I get the error shown in the attachment.

Where am I going wrong?
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

 

TinyPortal © 2005-2018