Recent

Author Topic: [SOLVED] how to gain access to StrUtils?  (Read 5694 times)

beampower

  • Newbie
  • Posts: 6
[SOLVED] how to gain access to StrUtils?
« on: July 18, 2017, 03:30:32 am »
I would like to use some of the functions defined in StrUtils.
I have added the line
   Uses StrUtils;
at the top of my program, but the compiler or whatever still can't find the file.
I also copied the object file to my program directory.
Is there a setting somewhere in my Free Pascal IDE?

Arrgh!
It was a case of operator error.
I restarted FPC and it worked fine.



« Last Edit: July 25, 2017, 07:37:53 pm by beampower »

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: how to gain access to StrUtils?
« Reply #1 on: July 18, 2017, 04:01:30 am »
I have added the line
   Uses StrUtils;
at the top of my program, but the compiler or whatever still can't find the file.
Looks strange. It should find it automatically without problems if your FPC installation is fine.
What is the error message?
Where exactly do you put "Uses"? It should go after "program programname;" (not at the top of the program, but after this line). And you shouldn't have two instances of "Uses" (one might be already added automatically). Posting the program code might be a good idea (use # button in edit).
Can you compile the examples? Or anything at all?
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: how to gain access to StrUtils?
« Reply #2 on: July 18, 2017, 04:30:12 am »
Should work out of the box...  :D

Code: Pascal  [Select][+][-]
  1. UNIT Unit1;
  2.  {$MODE OBJFPC}{$H+}{$J-}
  3.  
  4. Interface
  5.  USES
  6.   Classes, SysUtils, Forms, Controls, StrUtils;
  7.  
  8.  TYPE
  9.   TForm1 = Class(TForm)
  10.    Procedure FormClick (Sender: TObject);
  11.   End;
  12.  
  13.  VAR
  14.   Form1: TForm1;
  15.  
  16. Implementation
  17.  {$R *.LFM}
  18.  
  19.  
  20. Procedure TForm1.FormClick(Sender: TObject);
  21.  Begin
  22.   Caption:= 'MyProgram Caption';
  23.  
  24.   If AnsiContainsStr(Caption, 'My')
  25.   Then Caption:= 'YES';
  26.  End;
  27.  
  28. END.


EDIT: A simple program from within LAZARUS... exactly the same...
Code: Pascal  [Select][+][-]
  1. PROGRAM MyStrUtilsPrg;
  2.  {$MODE OBJFPC}{$H+}
  3.  USES
  4.   StrUtils;
  5.  
  6.  VAR
  7.   str: String;
  8.  
  9. BEGIN
  10.  str:= 'Deep Forest';
  11.  
  12.  If AnsiContainsStr(str, 'Deep')
  13.  Then WriteLn('Yes')
  14.  Else WriteLn('No');
  15.  
  16.  ReadLn;
  17. END.
« Last Edit: July 18, 2017, 04:47:25 am by RAW »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12838
  • FPC developer.
Re: how to gain access to StrUtils?
« Reply #3 on: July 18, 2017, 06:48:43 am »
The textmode IDE should have something like

c:\fpc\$FPCVERSION\units\$FPCTARGET\*

in the units tab of  options->directories. Note the trailing *

 

TinyPortal © 2005-2018