Re: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread Graeme Geldenhuys
Hi,

I don't know the PDF file format at all, but I would guess if you look at
the many pdf-to-text conversion tools, you will see what they have done. In
all likelihood, those conversion tools will be written in C, which you will
have to translate to Object Pascal - but that is normally not a difficult
task, just a boring task.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net:8080/fpgui/

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


Re: [fpc-pascal] MSEide+MSEgui rev.2.4

2010-11-02 Thread Graeme Geldenhuys
Op 2010-11-01 17:24, Brian Winfrey het geskryf:
 Which address should I be using?

release_2_4_2 is simply the tagged release of the future FPC 2.4.2
release - currently in beta testing.

The fixes_2_4 is already at version 2.4.3 and contains everything from
2.4.2 and more...

As Martin said, you can use either of those.


 It looks like the UUID and revision are the same while Last changed revision

Simply because both of those refer to the SubVersion repository as a whole.
Both those branches are in the save SubVersion repository, hence the same
UUID. Also a SubVersion repository uses a revision number across the whole
repository - not per branch.



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net:8080/fpgui/

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


[fpc-pascal] Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Bo Berglund
I am writing a serial communications program, which will connect to a
data acquisition instrument and download data. I am using FPC/Lazarus
in order to make the program platform independent so it can be
deployed also on an embedded Linux system even though it is developed
on Windows or Ubuntu on an x86 machine.

My problem is that the data downloaded are basically memory dumps of
an array of measure point records where the record contains various
data types including single precision floats, multi-byte integers and
character arrays. The instrument contains a Motorola microcontroller
so its endian is opposite that of the typical Windows PC.
When I wrote my Windows only program in Delphi 7 I had to introduce
swap functions to correct the endian of the various values after
downloading the memory dump. This worked fine but was a bit tedious to
do

Now, however, the problem may be complicated because the program may
well run on a CPU that is using the *same* endian structure as the
original instrument in which case of course the swaps should not be
done.
So I need some detector or other to decide if swaps are needed.
Is there some commonly used function to handle this or is there some
conditional directive one can use to control the compiler to do the
right thing depending on the target CPU endian?

Or maybe this is a moot question if FPC is only so far running on
platforms that have the same endian as x86 CPU:s? I have no
information on this though...

I can see at least these targets:
- Windows and Linux on x86 CPU:s
- Embedded Linux on ARM CPU:s


Bo Berglund

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


Re: [fpc-pascal] Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Marco van de Voort
In our previous episode, Bo Berglund said:
 Now, however, the problem may be complicated because the program may
 well run on a CPU that is using the *same* endian structure as the
 original instrument in which case of course the swaps should not be
 done.

Correct.

 So I need some detector or other to decide if swaps are needed.
 Is there some commonly used function to handle this or is there some
 conditional directive one can use to control the compiler to do the
 right thing depending on the target CPU endian?

See e.g. the CHM package. It has the same problem, the file structure is
little endian (since windows), but the package may run on e.g. PowerPC.

The routine in the url below is used for that. (in this case ntole, but
ntobe if your storage is bigendian)

http://www.freepascal.org/docs-html/rtl/system/ntole.html
http://www.freepascal.org/docs-html/rtl/system/ntobe.html

These routines are afaik inline and a no-op if the endianness is the same.

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


Re: [fpc-pascal] Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Thomas Schatzl
Hi,

 Or maybe this is a moot question if FPC is only so far running on
 platforms that have the same endian as x86 CPU:s? I have no
 information on this though...
 
 I can see at least these targets:
 - Windows and Linux on x86 CPU:s
 - Embedded Linux on ARM CPU:s

Sparc, PowerPC are big endian, there is an ARM big endian target too.

Use BEtoN, NtoBE if the source is known to be big endian.

(http://www.freepascal.org/docs-html/rtl/system/beton.html)
(http://www.freepascal.org/docs-html/rtl/system/ntobe.html)

Hth,
  Thomas

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


Re: Re[2]: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread Tomas Hajny
On Mon, November 1, 2010 21:52, José Mejuto wrote:
 .
 .
 So if you are looking for ASCII words, use PDF2Text and use the POS
 function over the result:

 function HaveString(Filename: String; TheString: string): Boolean;
 var
   F: TFileStream;
   S: String;
   AtPos: integer;
 begin
   Result:=false;
   F:=TFileStream.Create(Filename,fmOpenReadOnly);
   SetLength(S,F.Size);
   if F.Size0 then
   begin
 F.ReadBuffer(S[1],F.Size);
 AtPos:=Pos(UpperCase(TheString),S);
 if AtPos0 then
   Result:=true;
   end;
   F.Free;
 end;

If I understand it correctly, this assumes reading the whole file into
memory at once. Depending on the size of that file and other conditions,
this may or may not be advisable...

Tomas


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


Re: [fpc-pascal] Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Mark Morgan Lloyd

Thomas Schatzl wrote:

Hi,


Or maybe this is a moot question if FPC is only so far running on
platforms that have the same endian as x86 CPU:s? I have no
information on this though...

I can see at least these targets:
- Windows and Linux on x86 CPU:s
- Embedded Linux on ARM CPU:s


Sparc, PowerPC are big endian, there is an ARM big endian target too.

Use BEtoN, NtoBE if the source is known to be big endian.

(http://www.freepascal.org/docs-html/rtl/system/beton.html)
(http://www.freepascal.org/docs-html/rtl/system/ntobe.html)


All good clean fun. See ENDIAN_LITTLE and ENDIAN_BIG in the FPC 
Programmers' Manual, and also watch out for alignment issues.


I'd point out that if the embedded system is based on a Motorola chip 
and that if this defines that the format transferred across the link is 
big-endian, that this is basically the same as internet network order 
and a convenient hack is to use the endian-conversion functions 
associated with socket programming, i.e. HtoNL() etc.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Bo Berglund
On Tue, 02 Nov 2010 09:09:05 +0100, Bo Berglund
bo.bergl...@gmail.com wrote:

OK, I see that there are functions to convert a known BE or LE integer
value to the *native* order. This would in principle work across all
platforms where FPC is implemented so that is good news!

However now I have the semantics to deal with because of the way
people talk about big-endian and little-endian makes me think they are
opposite to my thinking...

So let me make a short example:
Assume a 4-byte integer value consisting of the B1, B2, B3 and B3
bytes where B1 is the MSB byte and B3 is the LSB byte.
They are arranged in memory at increasing addresses as:
B1 B2 B3 B4

Now comparing to how one writes a number 1234, this would look the
same i.e. the MSB comes first and the LSB last.

The end to me is the last (the right-most) byte. And that is the LSB.
So the end is LSB, the little part...

Therefore I would imagine that this is a LITTLE endian storage but is
it really what is the common definition?

And what happens when the memory itself holds 32 bits (or more) in
each address? Then everything is stuffed into the same single address
and the above example will fail...


Bo Berglund

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


Re: [fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Jonas Maebe

On 02 Nov 2010, at 12:41, Bo Berglund wrote:

 The end to me is the last (the right-most) byte. And that is the LSB.
 So the end is LSB, the little part...

Little endian means the little end comes first (with the little end 
referring to the least significant byte). See 
http://en.wikipedia.org/wiki/Endianness#Etymology for the origins of the term.

 And what happens when the memory itself holds 32 bits (or more) in
 each address? Then everything is stuffed into the same single address
 and the above example will fail...

Endianess is defined in terms of byte-addressable memory. Software running on 
such an architecture would have to emulate the behaviour of a little or big 
endian byte-addressable architecture when exchanging data with the outside 
world.


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


Re[4]: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread José Mejuto
Hello FPC-Pascal,

Tuesday, November 2, 2010, 11:02:18 AM, you wrote:

TH If I understand it correctly, this assumes reading the whole file into
TH memory at once. Depending on the size of that file and other conditions,
TH this may or may not be advisable...

Yes, and a pdf2text conversion will reduce the PDF file to a 1% of its
original size, so unless you handle 10 gigabyte PDFs should be not
problem in loading the whole file in memory.

I doubt that there are memory problems as running pdf2text will for
sure consume more memory that the result file size.

Of course if you will end up with 300 megabytes txt files then a
different approach would be needed using a buffer with a window over
the size of the searched text.

Also logic will be different if you would like to match one word,
several words, large sentences, sequeces of chars, etc.

-- 
Best regards,
 José

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


Re: [fpc-pascal] MSEide+MSEgui rev.2.4

2010-11-02 Thread Brian Winfrey

 The fixes_2_4 is already at version 2.4.3 and contains everything from
 2.4.2 and more...

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


Re: Re[4]: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread Marcos Douglas
On Tue, Nov 2, 2010 at 11:38 AM, José Mejuto joshy...@gmail.com wrote:
 Hello FPC-Pascal,

 Tuesday, November 2, 2010, 11:02:18 AM, you wrote:

 TH If I understand it correctly, this assumes reading the whole file into
 TH memory at once. Depending on the size of that file and other conditions,
 TH this may or may not be advisable...

 Yes, and a pdf2text conversion will reduce the PDF file to a 1% of its
 original size, so unless you handle 10 gigabyte PDFs should be not
 problem in loading the whole file in memory.

 I doubt that there are memory problems as running pdf2text will for
 sure consume more memory that the result file size.

 Of course if you will end up with 300 megabytes txt files then a
 different approach would be needed using a buffer with a window over
 the size of the searched text.

 Also logic will be different if you would like to match one word,
 several words, large sentences, sequeces of chars, etc.

I need to search several words. So, I can't use Pos function to search
each word.
My algorithm need to read each word (token) just one time to be fast.
I'll define each separator for each Token like space, comma, /,
\, enter, etc. For each token found, I'll search a combination in
my lists of words. If I found a match, I need to know which page the
token was found...

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


[fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Bo Berglund
On Tue, 02 Nov 2010 09:32:36 +0100, Thomas Schatzl
tom_at_w...@gmx.at wrote:

Hi,

 Or maybe this is a moot question if FPC is only so far running on
 platforms that have the same endian as x86 CPU:s? I have no
 information on this though...
 
 I can see at least these targets:
 - Windows and Linux on x86 CPU:s
 - Embedded Linux on ARM CPU:s

Sparc, PowerPC are big endian, there is an ARM big endian target too.

Use BEtoN, NtoBE if the source is known to be big endian.

(http://www.freepascal.org/docs-html/rtl/system/beton.html)
(http://www.freepascal.org/docs-html/rtl/system/ntobe.html)


Thanks, that helps a lot! Are there also overloaded BEtoN functions
for floating point values?
Like so:

function BEtoN(const AValue: Single):Single;

function BEtoN(const AValue: Double):Double;



-- 
Bo Berglund
Developer in Sweden

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


Re: [fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Felipe Monteiro de Carvalho
On Tue, Nov 2, 2010 at 7:04 PM, Bo Berglund bo.bergl...@gmail.com wrote:
 Thanks, that helps a lot! Are there also overloaded BEtoN functions
 for floating point values?

I think that single and double have always the same binary layout.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Vinzent Höfler
On Tue, 02 Nov 2010 21:39:31 +0100, Felipe Monteiro de Carvalho  
felipemonteiro.carva...@gmail.com wrote:


On Tue, Nov 2, 2010 at 7:04 PM, Bo Berglund bo.bergl...@gmail.com  
wrote:

Thanks, that helps a lot! Are there also overloaded BEtoN functions
for floating point values?


I think that single and double have always the same binary layout.


Mostly, I'd guess. But I wouldn't count on that.


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


Re: [fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Jonas Maebe

On 02 Nov 2010, at 21:39, Felipe Monteiro de Carvalho wrote:

 On Tue, Nov 2, 2010 at 7:04 PM, Bo Berglund bo.bergl...@gmail.com wrote:
 Thanks, that helps a lot! Are there also overloaded BEtoN functions
 for floating point values?
 
 I think that single and double have always the same binary layout.

That's incorrect, their endianess changes in the same way as that of integer 
data (except on ARM when using the FPA floating point unit, which uses its own 
special byte ordering).

There are no overloads of BEtoN() etc for floating point types in the system 
unit. You can convert them by putting them in a variant record with an overlaid 
floating point and integer field of the same size, and then swapping the 
integer field.


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

Re: Re[4]: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread DaWorm
On Tue, Nov 2, 2010 at 11:45 AM, Marcos Douglas m...@delfire.net wrote:

 If I found a match, I need to know which page the
 token was found...


That may prove most difficult, since I doubt your pdf to text will preserve
that very well.

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

[fpc-pascal] Re: Endian issues when porting FPC programs from x86 to other platforms

2010-11-02 Thread Bo Berglund
On Tue, 02 Nov 2010 22:53:21 +0100, Vinzent Höfler
jellyfish.softw...@gmx.net wrote:

On Tue, 02 Nov 2010 21:39:31 +0100, Felipe Monteiro de Carvalho  
felipemonteiro.carva...@gmail.com wrote:

 On Tue, Nov 2, 2010 at 7:04 PM, Bo Berglund bo.bergl...@gmail.com  
 wrote:
 Thanks, that helps a lot! Are there also overloaded BEtoN functions
 for floating point values?

 I think that single and double have always the same binary layout.

Mostly, I'd guess. But I wouldn't count on that.

I know for sure that on the Motorola system the floats are 4 bytes
(single precision) and have to be swapped in order to be used on
Windows. I have done it on Delphi already so I know this is a fact.
So now I need to find an endian corrector working with floating point
values as well...


-- 
Bo Berglund
Developer in Sweden

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


[fpc-pascal] TReader.ReadProperty

2010-11-02 Thread Fred Flinestone
hi all,

i am trying to replace the code from delphi to fpc where the code looks
like:

TYPE THackReader =class(TReader);

...

FReaderStream.Position := 0;
{$IFDEF FPC}
try
  FReader.ReadListBegin;
  while not FReader.EndOfList do begin
THackReader(FReader).ReadProperty(Obj1);
  end;
  Freader.ReadListEnd;
except
end;

{$ELSE}
FReader.Position := 0;
try
  while FReader.Position  FReaderStream.Size do
THackReader(FReader).ReadProperty(Obj1);
except
end;
{$ENDIF}


but my code in FPC raises an exception in ReadListBegin method and I am not
sure if it is correct way to read back properties to Obj1.

PS: How can I debug TReader class, because debuger steps over my calls from
TReader.

Thanx.

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

[fpc-pascal] How I can associate a text file name in UTF8?

2010-11-02 Thread Luis Fernando Del Aguila Mejía
How I can associate a text file name in UTF8?

Example:

Assign (F, 'タスク 01.txt');
Assign (F, 'Задание 01.txt');
Assign (F, '♕ Queen.txt');

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

Re: Re[4]: [fpc-pascal] Text scan in text files - (was: Full text scan - PDF files)

2010-11-02 Thread Marcos Douglas
On Tue, Nov 2, 2010 at 8:32 PM, DaWorm daw...@gmail.com wrote:


 On Tue, Nov 2, 2010 at 11:45 AM, Marcos Douglas m...@delfire.net wrote:

 If I found a match, I need to know which page the
 token was found...


 That may prove most difficult, since I doubt your pdf to text will preserve
 that very well.

Yeah... that is a big problem...
Maybe, if I have only one number in all line so this is the page number.

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