Re: [fpc-pascal] any free pascal standard function to compare a string against an array of string?

2018-10-10 Thread David Copeland
Dennis,

Look at AnsiMatchStr in strutils.

Dave.

On 2018-10-10 11:11 a.m., Dennis wrote:
> is there a function like
>   if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin
> ...
> end;
>
> is there such a function IsOneOf(TheSubString : String; const
> TheStrings : array of String) : Boolean
> ?
> if yes, what is its name and unit?
>
> Dennis
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


-- 
David Copeland
JSI Data Systems Limited
613-727-9353
www.jsidata.ca

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] ShortDateFormat

2015-05-07 Thread David Copeland
Hi all,

I am using the following bit of code to convert a date from an external
source.

var
timestamp: TDateTime;
event_date, event_time: string;
begin  
ShortDateFormat := 'm/d/y';
try
timestamp := StrToDateTime(event_date + ' ' + event_time);
except
// error handling ...
end;
end;

However, the compiler warns that ShortDateFormat is deprecated. Is there
another way to accomplish this?

Thanks,
Dave Copeland.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ShortDateFormat

2015-05-07 Thread David Copeland
Sorry, I think I just answered my own question :-! . Woult using the
TFormatsetting variant of StrToDateTime be the better way?

Dave.

On 05/07/2015 12:25 PM, David Copeland wrote:
 Hi all,

 I am using the following bit of code to convert a date from an external
 source.

 var
 timestamp: TDateTime;
 event_date, event_time: string;
 begin  
 ShortDateFormat := 'm/d/y';
 try
 timestamp := StrToDateTime(event_date + ' ' + event_time);
 except
 // error handling ...
 end;
 end;

 However, the compiler warns that ShortDateFormat is deprecated. Is there
 another way to accomplish this?

 Thanks,
 Dave Copeland.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ShortDateFormat

2015-05-07 Thread David Copeland
Thanks Bart.

On 05/07/2015 12:48 PM, Bart wrote:
 On 5/7/15, David Copeland david.copel...@jsidata.ca wrote:

 Sorry, I think I just answered my own question :-! . Woult using the
 TFormatsetting variant of StrToDateTime be the better way?
 Yes.

 Bart


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] IsATTY

2015-04-17 Thread David Copeland
This function is a part the unit oldlinux. Is there a replacement for it
somewhere? I have looked in the Linux, Unix, etc units but didn't see it.

Thanks,
Dave Copeland.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] IsATTY

2015-04-17 Thread David Copeland
On 04/17/2015 10:49 AM, Henry Vermaak wrote:
 On Fri, Apr 17, 2015 at 09:55:26AM -0400, David Copeland wrote:
 This function is a part the unit oldlinux. Is there a replacement for it
 somewhere? I have looked in the Linux, Unix, etc units but didn't see it.
 It's in termio.

 Henry
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Thanks very much!

Dave.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Setting execute bit for a Unix file

2014-07-31 Thread David Copeland
You could try FpSystem('chmod +x yourfilename');  // assuming the cwd is set

Dave.

On 07/31/2014 04:18 PM, Juha Manninen wrote:
 Hello

 How can I set a file flag (execute) using Pascal code in a Linux system?

 Juha
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Setting execute bit for a Unix file

2014-07-31 Thread David Copeland
I agree, you learn something new every day!

Dave.

On 07/31/2014 04:26 PM, Karoly Balogh (Charlie/SGR) wrote:
 Hi,

 Naaah, better use FpChmod() in BaseUnix unit:

 http://www.freepascal.org/docs-html/rtl/baseunix/fpchmod.html

 Charlie

 On Thu, 31 Jul 2014, David Copeland wrote:

 You could try FpSystem('chmod +x yourfilename');  // assuming the cwd is set

 Dave.

 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Tdbf Memo Field Issue, 2.6.2 vs 2.6.4

2014-06-17 Thread David Copeland
On 06/17/2014 07:07 AM, Reinier Olislagers wrote:
 Got some questions/remarks/workaround for you in the bug report...

 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Hi Reinier,

I've read your notes and questions.

I have been told, second hand, that the application is DBase IV, but I
will go to the source to confirm this, then report the results in the
bug tracker, along with answers to the other questions.

Thanks,
Dave.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Tdbf Memo Field Issue, 2.6.2 vs 2.6.4

2014-06-17 Thread David Copeland
On 06/17/2014 07:07 AM, Reinier Olislagers wrote:
 Got some questions/remarks/workaround for you in the bug report...

 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Answers are posted to the bug report.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Tdbf Memo Field Issue, 2.6.2 vs 2.6.4

2014-06-13 Thread David Copeland
Oops, I have now uploaded the program source to the Bug tracker. Also
reproduced here ...

program dbftest;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, dbf, db;
{ you can add units after this }

var
dbase: Tdbf;
s: string;
dbname: string;
cwd: string;
out_filename: string = 'test.csv';
outfile: Text;
header: boolean = false;
buf: string;
sep: string;
rec_count: integer = 0;
field_count: integer;
fieldname: string;
i, x: integer;

begin
Assign(outfile,out_filename);
Rewrite(outfile);
buf := '';
dbase := TDbf.Create(nil);
GetDir(0,cwd);
dbase.FilePathFull := cwd;
dbase.TableName:= 'BOX78.dbf';
dbase.ReadOnly := true;
dbase.Open;
field_count := dbase.FieldCount;
writeln('Table level is ', dbase.TableLevel, '. Number of fields is
', field_count);
sep := '';
for i := 0 to field_count - 1 do begin
writeln(dbase.Fielddefs[i].Name, ', ', dbase.FieldDefs[i].DataType);
buf := buf + sep + trim(dbase.Fielddefs[i].Name);
sep := ',';
end;
if header then writeln(outfile,buf);
while not dbase.EOF do begin
inc(rec_count);
buf := '';
sep := '';
for i := 0 to field_count - 1 do begin
fieldname := trim(dbase.Fielddefs[i].Name);
case dbase.FieldDefs[i].DataType of
ftString, ftMemo:
buf := buf + sep + '' +
trim(dbase.FieldByName(fieldname).AsString) + '';
ftInteger, ftSmallInt:
buf := buf + sep +
trim(dbase.FieldByName(fieldname).AsString);
end;
sep := ',';
end;
writeln(outfile,buf);
dbase.Next;
end;
writeln(inttostr(rec_count) + ' records read.');
dbase.Close;
dbase.Destroy;
Close(outfile);
end.

Dave.

On 06/13/2014 04:42 AM, Reinier Olislagers wrote:
 On 12/06/2014 20:37, David Copeland wrote:
 Added to the Bug tracker as Issue 26332.
 Hi Dave,

 Although you wrote in the bug report that the attached zip contains test
 source code, it doesn't. Could you attach a simple (FPC) test program to
 the bug report that demonstrates the problem?

 Thanks,
 Reinier
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Tdbf Memo Field Issue, 2.6.2 vs 2.6.4

2014-06-12 Thread David Copeland
Hi,

I think this is a bug

I wrote a simple program using Tdbf to export a dBase IV/w. Memo file to
a csv file. Accessing the memo field with
FieldByName(MEMOFIELD).AsString works fine on one machine but not a
second.

The first machine runs Suse 12.3 64-bit, with FPC 2.6.2 [2013/03/17] for
x86_64. My program work on this machine.

The second machine run Suse 13.1 64-bit wirh FPC 2.6.4 [2014/03/07] for
x86_64. On this machine AsString seems to return the whole block
including the 8 bytes of control info at the start of the memo file
block, first first 4 being $FF $FF $80 $00, and the second 4 being what
I can see is an offset to the end of the actual string.

I tried looking at the differences between the dbase code in the RTL but
could not see anything that would explain the difference in behaviour.

Added to the Bug tracker as Issue 26332.

Thanks,
Dave Copeland.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Generics Compile Error, 2.4.2 vs 2.6.0

2012-02-13 Thread David Copeland
Thanks very much. It now compiles! 

Dave.




-Original Message-
From: J.-c. Chu jc...@acm.org
Reply-to: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Generics Compile Error, 2.4.2 vs 2.6.0
Date: Tue, 14 Feb 2012 00:59:03 +0800

If you are compiling the unit in Delphi mode, you’ll need to use the
syntax of Delphi.

*  Generics are defined without the GENERIC keyword.
*  Generics are specialized without the SPECIALIZE keyword.
*  To define class-local types and variables, visibility specifiers need
   to be placed before the TYPE and VAR keywords.
*  Implementations of the methods of a generic class must include the
   type parameters of the class.

Please check if the attached file works.





___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Postscriptcanvas

2012-01-17 Thread David Copeland
Hi Felipe,

I had not thought that approach (a non-visual lcl program) to be
possible, but I will try it. Would I use the Nogui widgetset? Would such
a program run on a host where X was not installed? I am targeting only
Linux. I save the output to a file (SaveToFile). The user prints the
file if needed.

Thanks,
Dave. 

-Original Message-
From: Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com
Reply-to: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Postscriptcanvas
Date: Mon, 16 Jan 2012 14:14:44 +0100

If you are trying to print, why do you want to use PostScriptCanvas
directly? Are you targeting only UNIXes? How will you connect the
generated postscript to the printer? You have your own code for that?

I would recommend that you use the LCL in your project and print via
the Printer object, as normally done. LCL applications do not need to
be visual, just make an application without any forms.


-- 
David Copeland
JSI Data Systems Limited
613-727-9353.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Postscriptcanvas

2012-01-17 Thread David Copeland
Okay, I now understand the distinction between printing and drawing.
Using the LCL was only necessary to use it's Postscriptcanvas as that is
what I'm familiar with. But as this program needs to be able to run
without X, I will either puzzle out the FCL's fpcanvas, or just write
the postscript myself.

Thanks,
Dave.


-Original Message-
From: Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com
Reply-to: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Postscriptcanvas
Date: Tue, 17 Jan 2012 13:59:19 +0100

On Tue, Jan 17, 2012 at 1:40 PM, David Copeland
david.copel...@jsidata.ca wrote:
 I had not thought that approach (a non-visual lcl program) to be
 possible, but I will try it. Would I use the Nogui widgetset?

No, it doesn't implement printing.

 Would such a program run on a host where X was not installed?

No

 I am targeting only Linux. I save the output to a file (SaveToFile). The user 
 prints the
 file if needed.

Well, if you are not printing in your software then you are not doing
printing, only drawing. So the answer to my original questions should
have been Drawing. So with your requirements using the LCL is
probably not necessary. If you are targeting only linux then you can
probably use a command line execution to print the file.


-- 
David Copeland
JSI Data Systems Limited
613-727-9353.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Postscriptcanvas

2012-01-14 Thread david . copeland
Micheal,

Thank you. I was referring to LCL Postscriptcanvas unit which I use in GUI
programs. When I tried to use it in a non-GUI program, it could not be
found. Are these two really the same thing, or at least similar to use? If
not the same, can you point me to any documentation or example code? I did
find the source so I will try to puzzle it out from that.

Dave.



 On Fri, 13 Jan 2012, David Copeland wrote:

 Hi,

 Is it possible to use the PostScriptCanvas unit in a non-gui program?

 If you are talking about the pscanvas unit of FPC:
 Yes, that is what it is for.

 Michael.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal





___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Postscriptcanvas

2012-01-14 Thread david . copeland


 On Sat, 14 Jan 2012, david.copel...@jsidata.ca wrote:

 Micheal,

 Thank you. I was referring to LCL Postscriptcanvas unit which I use in
 GUI
 programs. When I tried to use it in a non-GUI program, it could not be
 found. Are these two really the same thing, or at least similar to use?
 If
 not the same, can you point me to any documentation or example code? I
 did
 find the source so I will try to puzzle it out from that.

 They try to achieve the same thing. The API is necessarily similar,
 since it is based on TFPCanvas.

 I suppose that meanwhile the Lazarus version is more complete as there are
 more people to support it, but it has more requirements as well.

 I will see if it can be separated out of lazarus, so it has no GUI
 dependencies.

 Michael.
 ___

Michael,

Thanks very much, that would would be great. I appreciate it.

Dave.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Postscriptcanvas

2012-01-13 Thread David Copeland
Hi,

Is it possible to use the PostScriptCanvas unit in a non-gui program?

Thanks,
Dave.




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal