Re: [fpc-pascal] eof strangeness

2006-05-02 Thread Bob Richards
John Coppens wrote:

 program testeof;
 
 begin
   if eof then
 writeln('EOF found')
   else
 writeln('No EOF found');
 end.
 
 This sample program doesn't return till enter is pressed.

That's correct and reasonable. You are terminating your program after an EOL 
(ENTER), If
you send it an EOF ^d it also responds reasonably.

$ ./testeof
   ^d entered at kybd
EOF found

Bob

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] ParamStr(0) bug??

2006-04-24 Thread Bob Richards
I have written a program who's behavior depends on the name by which it has 
been invoked.
This is not uncommon, for instance sendmail invoked as mailq behaves in a 
completely
different way.

Anyway, it all works as intended as long as I *copy* the executable to a 
different name.
However, if I use a symlink, the ParamStr(0) function doesn't work as I would 
expect. It
always returns the name of the executable not the name of the link to it.

Example:


Program test;

Begin
  WriteLn('This program was executed as: ',ParamStr(0));

end.



$ ./test
This program was executed as: /home/bob/pascal/test/test

cp test test1
./test1
This program was executed as: /home/bob/pascal/test/test1
$


$ ln -s test test1
$ ./test1
This program was executed as: /home/bob/pascal/test/test
$

-

Is there a way to make this work properly? Another method? Is this a bug?

Bob


-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ParamStr(0) bug??

2006-04-24 Thread Bob Richards
John Coppens wrote:

 You could try to access the environment variables - the '_' variable
 contains the command used to start the program. Just tested it - it shows
 the link.

Thanks John! That works a charm.

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] WinSock

2006-03-15 Thread Bob Richards

Can someone point me to the documentation for the winsock unit? It doesn't 
appear to exist
in the html docs, nor in the pdf doc either. A google search turned up nothing. 
The unit
exists in the source tree, I have it installed, but where is the doc??

I have fpc-2.0.2 running on Linux, and have the complete lib/units/i-386-win32 
library as
well. In the windows rtl directory there are other units, besides winsock; like 
windows,
wincrt, winevent, winmouse  Where are the docs for these??

TIA

Bob

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


Re: [fpc-pascal] Interactive SHELL?

2006-02-16 Thread Bob Richards
A.J. Venter wrote:

 Maybe not, depending on what OS you are working for, try using ncrt instead, 
 I 
 am pretty sure ncurses does NOT use raw mode so it may work.


Thanks for the reply A.J.

What I ended up using, and which worked perfectly was GetKeyEvent, 
TranslateKeyEvent(),
KeyEventToString(), and GetKeyEventChar(), all in the keyboard unit.

The keyboard unit gives you very good control/access to keyboard events, 
without mucking
with anything! The unit is a bit unfriendly, but powerful! A very good trade 
off.

The target platform for this job is Linux; but I believe the source should port 
to windows
as well.

Bob

-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] [Lazarus] Install from source on Linux Issue

2006-02-16 Thread Bob Richards
I am attempting to install Lazarus on my development Linux W/S

I retrieved the sources via svn, and also by downloading the tar ball. I change 
into the
top of the source tree, and gave the command make clean all as per the docs.
Here is what happens:

[EMAIL PROTECTED] trunk]$ make clean all
Makefile:118: *** Compiler Free Pascal Compiler version 2.0.2 [2006/02/13] for 
i386
Copyright (c) 1993-2005 by Florian
Klaempfl Fatal: No source file name in command line Fatal: Compilation aborted 
not found.
 Stop.

I recently upgraded freepascal from 2.0.0 to 2.0.2 by compiling from source. 
All of my
projects re-compile OK with 2.0.2, so I don't think it is the compiler's fault. 
I must be
doing something wrong?

FPC is executing with the proper paths, and a check of /etc/fpc.cfg shows all 
OK.

Free Pascal Compiler version 2.0.2 [2006/02/16] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
/usr/local/lib/fpc/2.0.2/ppc386 [options] inputfile [options]

Bob

-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [Lazarus] Install from source on Linux Issue

2006-02-16 Thread Bob Richards
Bob Richards wrote:

Hm. well, this must be an issue with my fpc install! I went and got the 
new fpdocs
via svn, did a make html and:

[EMAIL PROTECTED] fpcdocs]$ make html
Makefile:118: *** Compiler Free Pascal Compiler version 2.0.2 [2006/02/13] for 
i386
Copyright (c) 1993-2005 by Florian Klaempfl Fatal: No source file name in 
command line
Fatal: Compilation aborted not found.  Stop.

Same error! I never use make in my pascal programing, so I don't know if this 
is new or
something I just discovered.

I am using:
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-redhat-linux-gnu


-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Interactive SHELL?

2006-02-15 Thread Bob Richards
Hi All:

What I need to do is to shell out to another program [GNUpg] and allow the user 
to
interact with it (enter a pass phrase).

I have tried all the  FpExec routines, the Shell routines etc. They ALL 
execute gpg
correctly, with the proper command-line args, I see gpg's response on the 
console screen,
and it's request for a pass phrase, but, the user can NOT interact with it as 
the keyboard
is dead.

Now, this is understandable, since it is the main program which issued the 
shell command,
and any input would have to come from the entity opening the shell (the parent 
program,
not the console user).

Is there a way to re-direct the local console kybd to the new shell, allowing 
the user to
interact with gpg? Or is there another way to do this? Perhaps shelling out is 
not the
proper way to handle this?

The program is being compiled for Linux, with FPC 2.0.0

Best Regards
Bob

--
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interactive SHELL?

2006-02-15 Thread Bob Richards
Marco van de Voort wrote:

 
 Do you use units or libraries that might put the terminal in raw mode?
 Ncurses,crt, video?

I am using crt for the readkey function in one of my procedures. No ncurses, 
no video. I
am also smart-linking, so the only function compiled in from crt SHOULD be 
readkey.

I will look at unit CRT, and see if perhaps there is a termonal mode command I 
can issue.
Thanks.

Bob

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interactive SHELL?

2006-02-15 Thread Bob Richards
Jonas Maebe wrote:
 

 No, because the crt unit contains initialisation code, and
 initialisation code of a unit is obviously always linked in and
 executed. This initialisation code puts the terminal in raw mode...

Thanks Jonas! That was the issue. So, I will just have to write my own readkey 
routine,
and lose crt. Not a big deal.

Thanks again

Bob


-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interactive SHELL?

2006-02-15 Thread Bob Richards
Marco van de Voort wrote:

 Try, - for testing purposes - to remove crt and use more basic input
 (readln), and see if it makes the problems disappear.

Indeed! Problem gone! now to hide the user's typying from the screen. I was 
using readkey
and echowing back a * during password input. I will have to do it another way.

Bob

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A simple exception handling question

2006-01-29 Thread Bob Richards
Marco van de Voort wrote:

 You are aware of the fact that the .o's belong to units too?
 
 Delphi .dcu = fpc .ppu + fpc .o !

Dumb me! Nope! And this was the problem. I just copied the new strutils.ppu 
file into
/usr/lib/fpc/... NOT the strutils.o as well. So when the executable got 
linked it got
linked with the wrong (old un-patched) code.

It now works! Thanks  Guess I will have to pay more attention to the 
compiler, as I
tend to use the compiler as if it were God, and any problems are obviously 
mine and mine
alone.

Lesson Learned! thank you all very very much.

Is there a list of similar patches to bugs? I would like to nip the next one 
in the bud
so to speak. :-)

An Aside: This FPC has allowed me to ressurect so much of my source-code from 
the early
days, of ARPANET, and FIDONET, that it has become a real big asset (not to 
mention a lot
of fun)! I drooled when I saw all the new functions and procedures 
available Nifty
stuff! What I have to keep in the back of my mind, is, that this is 
User-Supported and
as such will have the occasional bug.




-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A simple exception handling question

2006-01-29 Thread Bob Richards
L505 wrote:

 
 Which installation/ide are you using for FPC, just FP-IDE or commandline, or 
 Lazarus?

Free Pascal Compiler version 2.0.0 [2005/05/15] for i386
I don't use an IDE, I simply use vi to edit source, and then fpc sourcefile 
to produce
the executable.
 
 .A, .O, .ppu files and etc. will be in a special folder called units, 
 whereas the

Yeah I found them in the rtl units directory... along with the .ppu, and .o 
files. After
your first reply, I did a quick locate *.A found nothing :-( Of course, on my 
system
they are .a I instantly ASSUMED the lack of .A files, was the reason I couldn't 
ever
smartlink a program. I had been using {$SMARTLINK ON} at the top of the source 
file, but
this NEVER did anything. the -XX was the trick.

So, I recompiled strutils with the patch and with the -CX command line, and I 
still
couldn't find strutils.a HOWEVER, I did find a new libpstrutils.a. Moving that 
over to
/usr/lib/fpc/2.0.0/units/i386-linux/rtl and recompiling my program with the -XX 
produced a
properly working elf, 1/3 the size of the old elf. -XX and -CX are now 
permanantly in
/etc/fpc.cfg VERY NICE, and THANKS all!

I also appreciate your patience with this...

Bob

-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] A simple exception handling question

2006-01-28 Thread Bob Richards
I must not understand a fundamental concept here. Perhaps someone can point me 
in the
right direction.


{$mode Delphi} //Delphi or objfpc same results


program hextest; // or why can't I trap an exception?


 uses Sysutils,strutils;


 var
  b:byte;
  hex:string;


begin
  Write('Enter a hex String: ');
  ReadLn(hex);
   Try
 b:=Hex2Dec(Hex);
   Except
On EConvertError do
Begin
  WriteLn(hex,' is not a valid hex number! Terminating...');
  Halt
end
   end;
  WriteLn('Hex value ',hex,' is decimal value: ',b)
end.

Upon execution:

$ ./hextest
Enter a hex String: 0A
Hex value 0A is decimal value: 10

Cool!

$ ./hextest
Enter a hex String: FF
Hex value FF is decimal value: 255

Still Cool!

$ ./hextest
Enter a hex String: ZZ
Hex value ZZ is decimal value: 0

Certainly NOT cool!

According to the docs on function Hex2Dec in Strutils:

If S does not contain a valid hexadecimal value, an EConvertError exception 
will be raised.

So, what profound lack of understanding am I suffering from? Anybody?

Bob


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


Re: [fpc-pascal] A simple exception handling question

2006-01-28 Thread Bob Richards
I probably should have stated which compiler I was using If it matters:

$ fpc hextest.pas
Free Pascal Compiler version 2.0.0 [2005/05/15] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: Linux for i386
Compiling hextest.pas
Linking hextest
26 Lines compiled, 0.6 sec

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A simple exception handling question

2006-01-28 Thread Bob Richards
Michalis Kamburelis wrote:

 There's a bug in Hex2Dec implementation -- it returns 0 instead of
 raising EConvertError. Here's a patch:
 
 Index: strutils.pp
 ===
 --- strutils.pp(wersja 2298)
 +++ strutils.pp(kopia robocza)
 @@ -1156,7 +1156,7 @@
  HexStr:='$'+ S
else
  HexStr:=S;
 -  Result:=StrTointDef(HexStr,0);
 +  Result:=StrToint(HexStr);
  end;
 
  function Dec2Numb(N: Longint; Len, Base: Byte): string;
 ___

First, thanks for the reply; I applied the patch, it applied without a problem, 
verified
the new StrUtils.pp source, all OK as per the patch. Recompiled strutils.ppu. 
The function
still returns a zero on error.

Is there another patch I need as well?
This is fpc 2.0.0 on Linux, but at this level I don't think it should matter.

Sorry for being dense :-(

Bob

-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Questions on Documentation

2005-10-11 Thread Bob Richards
Tomas Hajny wrote:

 I'd suggest to fill your comment as a Wishlist type
 bug record for area Documentation in our bug repository, so it doesn't
 get forgotten.

Will do when I get a moment! This sort of reference is what I think is needed.

 
 My (simplified) categorization to get you started (before we manage to get
 it to our documentation):
 
 1) procedural programming, short strings, cross-platform: ...
 

Thank you very much Tomas! This goes a long way to alleviate the frustration. 
It gives be
a hint as to where to go looking for something needed.

If anyone else here finds Tomas' summary useful, I have done a quick and dirty 
html
conversion for easy inclusion into the fpctoc file. Here:
http://www.tamara-b.org/users/bob/AddToDoc.html

Bob



-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Questions on Documentation

2005-10-11 Thread Bob Richards
A list member wrote me a private email and enclosed a very useful Korn Shell 
script which
he posted here on the list in the past; it produced this:
http://www.tamara-b.org/users/bob/rtl_pf_index.html Document.

With this, as well as Tomas' file added to the docs, I am now cooking! Thanks!!

Bob


-- 
PGP Encrypted E-Mail Prefered
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Questions on Documentation

2005-10-10 Thread Bob Richards
Hi All:

I am new to this list, but not new to pascal programming. I have been writing 
pascal code
since Turbo pascal Version 3.0.

I have installed Free Pascal Ver. 2.0.0, running it on a Linux WorkStation, and 
am writing
CGI apps which run on a Linux server. I love FPC! It keeps me honest, and my 
code safe,
and easy to follow years later.

I miss the old DOS IDE of Borland-of-Old; FP is somewhat OK, and Lazarus is way 
too much
for system programming. But that's no real problem, VI does me just fine!

The biggest problem I have run into is the function/procedure documentation. 
While very
complete, and clearly written, it is organized in a way making it difficult to 
find
things. Similar functions and procedures are scattered among various Units, 
making things
difficult to locate. What I need is a reference document, listing procedures 
and functions
by category (or at the very least alphabetically as in the Turbo Pascal 5.0 
Reference
guide). All disk-file routines for instance, listed, in one place.

I was reviewing some code I wrote, and discovered that some functions I had 
written were
now part of an FPC Unit (more elegantly coded I might add) Is there such a
cross-reference document somewhere? If not, can one be generated using 'fpcdoc'?

Are there any printed manuals? Has someone written a good book which would be a 
good
reference? Not knowing any OOP (nor having a desire to) would purchasing a book 
on Delphi
help me in my FPC documentation quest? Any sugestions on which one?

Best Regards
Bob

-- 
PGP Encrypted E-Mail Preferred
Public Key at: http://www.tamara-b.org/~bob/pubkey.asc
.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal