According to Orlando Llanes:
>
> Ok, I know you guys are gonna shoot me for this, but here goes anyway...
No. To become shot by myself, you must do more than this. ;-)
> My question is about Pointers, what I want to know are 3 things..
> 1) What is the format of a pointer? Is it 3 bytes (selector--1 byte,
> base address--2 bytes)? Or is it 4 bytes?
On iX86-based machines, pointers have four bytes; all of them "offset"
(that's what you probably mean with "base address"). …
[View More]GPC works in just
one memory segment with a maximum length of 4GB, while 16-bit compilers
usually work in many memory segments of 64kB each.
On other machines, pointers are different; e.g. on the DEC Alpha, a
pointer has eight bytes.
> 2) If I performed pointer arithmetic that works under MS-DOS, will it
> also work under Linux without modification?
Yes. Provided you use GPC's pointer arithmetic as implemented in
gpc-somewhere-in-may-or-so. Casts to `Word' and such are *not*
portable.
> 3) How do I create a generic pointer? Can I just use "Pointer"? reason
> I ask is because I tried plain Pointer once, and it didn't work.
It works now. :-)
> Another question I have now while we're at it, is the latest version of GPC
> posted on the FTP site? Or is it still in patched versions? I want to
> upgrade, but I don't want to mess with patches unless I could upgrade from
> 2.01 Where can I find the upgrade?
>From 2.01? What's that?
While the official version of GPC is still 2.0, the latest beta version
that is available in binary form is gpc-970714, available via ftp at
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/beta/binary/. Some
patches to gpc-970714 already exist on Agnes, too, but they are no
official new beta yet. Due to administrative problems :-(some paper war
must be resolved first - sigh)-: I am retaining more recent sources, but
some bug fixes have been posted to this list now and then ...
Hope this helps,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski(a)uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
[View Less]
<grin>
> No. To become shot by myself, you must do more than this. ;-)
Do you have access to these machines for beta-testing? That reminds me, are
there definitions for the environment GPC is compiling for? For example:
{$ifdef DOS}
DOS specific stuff
{$endif}
{$ifdef Alpha}
Alpha specific stuff
{$endif}
etc.
> On other machines, pointers are different; e.g. on the DEC Alpha, a
> pointer has eight bytes.
How do I set a pointer to point to the VGA (for example) in a way …
[View More]that can
be ported to at least Linux? I'm going to start work again on my game lib
(graphics part), and M13h would be a start :) Another thing is how do I
modify the contents referenced by the pointer? Writing a byte so it's
portable, writing a word so it's portable, etc. My ultimate goal is to port
this lib to PMode DOS, Mac, '95, Linux, X, and whatever other platform I
can get my grubby hands on, but I'll settle for PMode DOS for now :)
> Yes. Provided you use GPC's pointer arithmetic as implemented in
> gpc-somewhere-in-may-or-so. Casts to `Word' and such are *not*
> portable.
Cool :)
> It works now. :-)
Will check it out!
> While the official version of GPC is still 2.0, the latest beta version
> ...
> patches to gpc-970714 already exist on Agnes, too, but they are no
Gee, I wonder why I don't like politics, hmmm :P
> official new beta yet. Due to administrative problems :-(some paper war
> must be resolved first - sigh)-: I am retaining more recent sources, but
> some bug fixes have been posted to this list now and then ...
See ya!
Orlando Llanes
[View Less]
Hello!
According to John Miller:
>
> I wrote earlier about problems with gpc making on solaris 2.5 (SunOS 5.5).
> [...]
> ./xgcc -B./ -DIN_GCC -g -I./include -DNO_MEM (wrapping)
> -DNO_LONG_DOUBLE_IO -O0 -I. -c ./enquire.c
> [...]
This looks as if you are compiling GPC in the same directory where the
source is. Did you already try to use a different directory for the
source and the objects? Both for GCC and GPC? This is known to fix
many problems.
Also, recent …
[View More]beta versions of GPC, available at
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/beta/, are known
to cause less problems than gpc-2.0 when compiling them on UNIX
machines. (And they are more stable anyway.;-)
Hope this helps a little,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski(a)uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
[View Less]
Ok, I know you guys are gonna shoot me for this, but here goes anyway...
My question is about Pointers, what I want to know are 3 things..
1) What is the format of a pointer? Is it 3 bytes (selector--1 byte,
base address--2 bytes)? Or is it 4 bytes?
2) If I performed pointer arithmetic that works under MS-DOS, will it
also work under Linux without modification?
3) How do I create a generic pointer? Can I just use "Pointer"? reason
I ask is because I tried plain Pointer once, and it …
[View More]didn't work.
Another question I have now while we're at it, is the latest version of GPC
posted on the FTP site? Or is it still in patched versions? I want to
upgrade, but I don't want to mess with patches unless I could upgrade from
2.01 Where can I find the upgrade?
Thanks in advance!
--
See ya!
Orlando Llanes
[View Less]
Hello!
According to Fred:
> I'd like to use GPC for some simple CGIs I'm writing for my own server.
>
>To accomplish this I need to know how to:
>
>1) Read from various environment variables like $QUERY_STRING.
>2) Read from Standard Input.
>
>Any and all help greatly appreciated.
>
Here's a litte demo program (i learn best with demo programs :-).
It declares the "getenv" function itself and doesn't need any other unit.
But there is a "bpcompat" unit for that and …
[View More]a lot of other useful things.
{$x+} (* <- Enable extended syntax *)
PROGRAM cgi1(Input, Output);
TYPE
tStr255 = String(255);
FUNCTION GetEnv(Name : pChar):pChar; C;
(* get access to the getenv funktion in c rtl *)
VAR
St : tStr255;
BEGIN
(* write some environment variables *)
WriteLn(' TERM : ', GetEnv('TERM'));
WriteLn(' SHELL: ', GetEnv('SHELL'));
(* now echo all stdin *)
WHILE NOT Eof(Input) DO BEGIN
ReadLn(Input, St);
WriteLn('>>', St);
END;
END.
Hope this helps,
Achim
[View Less]
I'd like to use GPC for some simple CGIs I'm writing for my own server.
To accomplish this I need to know how to:
1) Read from various environment variables like $QUERY_STRING.
2) Read from Standard Input.
Any and all help greatly appreciated.
Fred
pismo(a)mclv.net
Hello, Miguel!
Hello, everybody! (* Below are some words about ISO vs. Borland Pascal ... *)
According to João Miguel Domingos:
>
> Thank you for your very useful help. I apolagize about my constant
> questions but I feel like someone in the desert searching for water.
No problem. One day, you will read another one's question on this
list, know the answer, and "become water" yourself. :-)
> This code was gaved by you and I think it is working properlly. After
> assigning …
[View More]the file I'm doing :
>
> reset(f1);
> while not eof(f1) do
> begin
> seekread(f1,n); (n is integer);
> end;
>
> After the seekread I want to read one record to the variable r1 of type
> tf1. What function do I use to do this.
`read'.
> I know that GPC contains a get
> procedure but the only parametres that it accepts if the file variable.
You can use `get' as well, see below.
The following example program worked on my Linux box:
Program Test (output, f1);
type
tf1 = record
preco : integer;
idade : integer;
titulo : string[90];
end;
f1file = file[1..1000] of tf1;
var
r1 : tf1;
f1 : f1file;
n : integer;
Procedure FAssign ( Var t: f1file; Name: String );
Var
b : bindingtype;
begin
unbind(t);
b:=binding(t);
b.name:=name;
bind(t,b);
b:=binding(t);
end;
begin
FAssign (f1, 'test.dat');
rewrite(f1);
for n:= 1 to 3 do
begin
r1.preco:= n;
write (f1, r1);
end (* for *);
FAssign (f1, 'test.dat');
reset(f1);
seekread(f1,2);
get (f1); (* Read a value into the "file variable" `f1^' *)
r1:= f1^; (* Assign the value of the file variable to `r1' *)
writeln (r1.preco); (* Must be 2 *)
end.
Or, using `read' (compatible to Borland Pascal which does not support `get'):
reset(f1);
seekread(f1,2);
read (f1, r1); (* Same as `get (f1); r1:= f1^'; *)
writeln (r1.preco); (* Must be 2 *)
Without the `(output, f1)' in the program's headline it does not work. :-(
I consider this a bug in GPC; others might consider this a feature.
Okay, ISO Pascal, as far as I have understood it, requires all files to appear
in the program headline. While GPC partially supports this, I am sure that it
does not yet comply to the requirements of the standard. OTOH, I consider
this a bug anyway: I see no use for this, and - correct me if I am wrong -
makes it a pain to write a large program (> 50000 lines) which reads and
writes *many* files at *many* uncorrelated places.
Thus, GPC's standard behaviour should be as follows:
* Accept program headline parameters, but don't require them.
* If program headline parameters are given, do all checks required by ISO.
* If they are not given, allow to do everything with files which is
allowed by UCSD and Borland Pascal.
* With `--standard-pascal', `--extended-pascal', or whatever, these
parameters are required. (Already the case.)
I would be glad if somebody sent me test programs which show deficiencies in
GPC's treatment of program headline parameters - both concerning ISO Pascal
requirements and the treatment of files in UCSD/Borland Pascal.
For example, GPC should work with the following (but doesn't):
Program Test; (* Doesn't work without `F' parameter *)
Var
F: file of Integer;
n: Integer;
begin
Assign ( F, 'test.dat' );
rewrite ( F );
for n:= 0 to 5 do
write ( F, n );
close ( F );
reset ( F );
Seek ( F, 4 ); (* `Seek' unknown; must use `SeekRead' *)
read ( F, n );
writeln ( n );
close ( f );
end.
There are probably more, independent cases where GPC fails to compile valid
UCSD/Borland Pascal. And a similar example can certainly be constructed for
valid Extended Pascal rejected by GPC - or invalid Extended Pascal accepted
by "gpc --extended-pascal". Please help to improve GPC by finding all these
cases and posting test programs here!
Greetings,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski(a)uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
[View Less]
Dear Peter G.
Thank you for your very useful help. I apolagize about my constant
questions but I feel like someone in the desert searching for water. All
my actual problems are with accessing files. The description of my file
is the following:
type
tf1 = record
preco : integer;
idade : integer;
titulo : string[90];
end;
var
r1 : tf1;
f1 : file[1..1000] of tf1;
Now i'm using the following routine to assign a types file:
Procedure FAssign ( Var somefile; …
[View More]Name: String );
Var
t : bindable text absolute somefile;
b : bindingtype;
begin
unbind(t);
b:=binding(t);
b.name:=name;
bind(t,b);
b:=binding(t);
end;
This code was gaved by you and I think it is working properlly. After
assigning the file I'm doing :
reset(f1);
while not eof(f1) do
begin
seekread(f1,n); (n is integer);
end;
After the seekread I want to read one record to the variable r1 of type
tf1. What function do I use to do this. I know that GPC contains a get
procedure but the only parametres that it accepts if the file variable.
Can you help me once more ? Please !
Best regards
Joao Miguel Domingos
[View Less]
Hello!
(* I am in hurry ... just some short notes ... *)
According to João Miguel Domingos:
> [...]
> I'm defining the record variable this way:
>
> r1 : tf1
>
> and the file variable like this:
>
> f1 : file of tf1;
>
> Is this correct ???
Yes. Maybe it is necessary to write `file [ 1..1000 ] of tf1;'.
> I want to assign, reset, read and seek the file to
> read records in a sequencial way or just read one in position "x".I have
> downloaded …
[View More]the Peter's G. system.pas unit that have the bin* functions,
> but I don't know how to use them.
These are not written by me, but by The African Chief, and they are
designed to work with "untyped" files, AFAIK.
For what you have in mind, use the `Assign' procedure from the `System'
Unit. Maybe you need to replace the untyped `Var' parameter with
`Var foo: tf1File' (with tf1File being `bindable file [ 1..1000 ] of tf1;')
and so on.
> Do you have any other functions to
> work with this type of files ???
`SeekRead', `SeekWrite', `SeekUpdate'.
> Please help me with this problem. My boss is geting very bored with me
> !!!
Good luck!
(* I am back in ~2 hours ... *)
Hope this helps,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski(a)uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
[View Less]