* Moved (from: gpc) by Berend de Boer using timEd 1.10.b3+.
Peter Gerwinski wrote in a message to Berend de Boer:
PG> I tried to use Extended Pascal "binding" to assign a file
PG> variable to an external -- existing -- file. I just copied
PG> the "Assign" pro- cedure by Berend as published in
PG> borland2ep.doc. It does not always work: I often get a
PG> runtime error saying that the file did not exist.
If you can repeat it, compile with another Extended Pascal compiler, for …
[View More]example Prospero's one. If that fails too, there is really something wrong with the code. But I suspect gpc. You're using which OS?
Groetjes,
Berend (-:
fido: 2:281/527.23
email: berend(a)beard.nest.nl
[View Less]
According to Harry Reed:
> In the users' manual chapter "About Pascal and Extended Pascal
> languages"
> there is a small example on how to initialize constant strings. When I
> try
> compiling the fragment with gpc 1.2(2.7.2)#7 I get the error messages
> as showm below. Is this a valid bug or am I just doing something wrong?
Extended Pascal initialized *structured* variables are not (yet)
implemented into GPC, only (parts of) Borland Pascal style initializers.
However …
[View More]some fragments of Extended Pascal initializers *do* exist in
gpc-parse.y, but I don't know when they will work.
Everybody be invited to help implementing this!
> MyStrings : array [1..MyStringsCount] of Ident value [
Square brackets do not work. Use parantheses instead. ^
> 1:'EXPORT'; 2:'IMPLEMENTATION'; 3:'IMPORT';
You may specify Indices etc., but they are ignored completely.
Even worse: Initialization of Strings does not work at all.
Only "simpler" types, i.e. array/record combinations containing
Integers, Reals, etc. work.
This is a known bug, but I forgot to document it.
Thank you for pointing me to it.
> PS: Great work on GPC! Keep it up!!!!
Thanks a lot. :-) :-)
I will continue unless somebody makes big efforts to stop me. ;-)
Peter
[View Less]
Hi,
In the users' manual chapter "About Pascal and Extended Pascal
languages"
there is a small example on how to initialize constant strings. When I
try
compiling the fragment with gpc 1.2(2.7.2)#7 I get the error messages
as showm below. Is this a valid bug or am I just doing something wrong?
Cheers,
Harry Reed
doon(a)hrc.nevada.edu
PS: Great work on GPC! Keep it up!!!!
source program --- cut here --- 8< --- cut here --- 8< --- cut here ---
program test;
const
…
[View More]MyStringsCount = 5;
type
Ident = string(20);
var
MyStrings : array [1..MyStringsCount] of Ident value [
1:'EXPORT'; 2:'IMPLEMENTATION'; 3:'IMPORT';
4:'INTERFACE'; 5:'MODULE'];
begin
end.
compiler output --- cut here --- 8< --- cut here --- 8< --- cut here ---
test.pas: In function `test':
test.pas:9: parse error before `:'
test.pas:9: Set constructor elements must be of ordinal type
test.pas:9: missing comma
test.pas:9: parse error before `;'
test.pas:9: missing comma
test.pas:9: parse error before `:'
test.pas:9: Set constructor elements must be of ordinal type
test.pas:9: missing comma
test.pas:9: parse error before `;'
test.pas:9: missing comma
test.pas:9: parse error before `:'
test.pas:9: Set constructor elements must be of ordinal type
test.pas:9: missing comma
test.pas:9: parse error before `;'
test.pas:10: missing comma
test.pas:10: parse error before `:'
test.pas:10: Set constructor elements must be of ordinal type
test.pas:10: missing comma
test.pas:10: parse error before `;'
test.pas:10: missing comma
test.pas:10: initial value is of wrong type
[View Less]
Dear readers of the GPC list,
we herewith announce a pre-release of GPC version 1.2,
based on GNU C 2.7.2.
This is a beta test release. We ask you to try the new GPC
version on as many different platforms as possible, isolate
bugs, correct the documentation, etc.. Once we know it is
stable enough, we will do the "official" 1.2-2.7.2 release.
New features:
* easier to compile and install, also for cross-compilation
* Texinfo documentation
* More stable (Borland-style) …
[View More]objects
* "String" bug fixed (see the old `PROBLEMS' file)
* Extended Pascal "export foo = all" extension
* PXSC operator fragments (redefineable symbols)
* Precompiled Module/Unit interfaces (needn't #include
the interface any longer)
* AutoMake facility (automatically compile Modules/Units
which have been changed)
Source and binaries for DJGPP, EMX, Linux, FreeBSD, and
IRIX5 are available per anonymous ftp from
agnes.dida.physik.uni-essen.de
in the directory
gpc-2.7.2
(They also will be available on kampi.hut.fi, soon.)
Have fun,
Jan Jaap
<J.J.vanderHeijden(a)student.utwente.nl>
Peter
<peter.gerwinski(a)uni-essen.de>
[View Less]
Hello All,
I promised to create a System.pas unit, here is a large part of it (see next
message).
It seems to work on gnu-win32 systems (I tested it in a NT workstation). It
probably also works on BSD unix systems.
I used gpc 2.6.3 (which was more useful than I expected and have
said so in the past )-: ), but I still encountered some strange things.
So here my comments:
1. how do you use the __unsigned__ prefix?
2. Instead of using __byte__, etc. ranges should be better as Juki already
…
[View More]suggested.
3. nil assignment to void pointer unacceptable? (var p: ^void; p := nil; )
Things I found missing:
- schema types ( type t(max:integer) = array[0..max] of double; )
- function result variables ( function f(p: integer) = Result: integer; )
- pre-initialized variables
- renaming in export clause
I like to here comments,
Berend.
[View Less]
{ Created: 1996-07-26
System module for emulating the Borland Pascal System unit. This one
is specific for the GNU Extended Pascal implementation and provides a
System.Pas interface specifically to emulate the 16-bit Borland Pascal
compilers.
Copyright (C) 1996 Berend de Boer <berend(a)pobox.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either …
[View More]version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Notes:
- This one has hardcoded errorcodes!! It probably does not work on every
machine. One really need to convert errno.h and stat.h first to make
it portable. But I'll do that when I complete the Extended Pascal
Posix interface for GNU Pascal.
- assumes all Extended Pascal compilers have the local addition to
provide an additional parameter to the Halt procedure.
- certain procedures are almost untranslatable as Addr, Move and Str. They are
therefore not translated, but require a change to the source code
- there is no Assign or Close procedure for a file type variable, only for a
text type variable.
- Rename does not work for some reason.
To do:
- Append
- FilePos
- FileSize
- Flush
- Rename
- Seek
- Truncate
$Date: 96-08-14 9:45 $
$Revision: 1 $
$Log: /Extended Pascal/Borland/GPC/system.pas $
*
* 1 96-08-14 9:45 Berend
* Borland Pascal's system unit for Extended Pascal, as far as applicable.
}
module System interface;
export
System = (shortint, byte, word, longint, PChar, pointer, string255,
HeapError, ExitCode, PrefixSeg,
Assign, BPChDir => ChDir, Close, Copy, Dec, Delete, Erase,
GetDir, GetMem,
Inc, IOResult,
MaxAvail, MemAvail, BPMkDir => MkDir,
ParamCount, ParamStr,
BPRename => Rename, BPRmDir => RmDir,
UpCase);
type
shortint = __byte__ integer;
byte = __byte__ integer;
word = __short__ integer;
longint = integer;
TChar = array[0..MaxInt] of char;
PChar = TChar;
pointer = void;
string255= string(255);
var
HeapError: pointer; { Heap error function }
{?ExitProc: Pointer; { Exit procedure }
ExitCode: Integer; { Exit code }
{?ErrorAddr: Pointer; { Runtime error address }
PrefixSeg: Word; { Program segment prefix }
InOutRes : integer; { I/O result buffer }
procedure Assign(var t: text; protected Name: string);
procedure BPChDir(protected s: string);
procedure Close(var t: text);
function Copy(protected s: string; Index: integer; Count: integer): string255;
procedure Dec(var i: integer);
procedure Delete(var s: string255; Index: integer; Count: integer);
procedure Erase(var f: text);
procedure GetDir(D: byte; var s: string);
procedure Inc(var i : integer);
function IOResult : integer;
function MaxAvail: longint;
function MemAvail : longint;
procedure BPMkDir(protected s: string);
function ParamCount: word;
function ParamStr(Index: word): string255;
procedure BPRename(var f: text; protected Newname: string);
procedure BPRmDir(protected s: string);
function UpCase(Ch: char): char;
end.
module System implementation;
import
StandardOutput;
{ support routines }
const
MaxPath = 4096;
type
TPath = array[0..MaxPath] of char;
function StrPas(Str: PChar): String255;
var
i: integer;
s: string255;
begin
i := 0;
s := '';
while Str[i] <> Chr(0) do begin
s := s + Str[i];
i := i + 1;
end;
StrPas := s;
end; { StrPas }
function unlink(path: __cstring__): integer; c;
function chdir(path: __cstring__): integer; c;
function getcwd(var buf: TPath; size: integer): PChar; c;
function mkdir(path: __cstring__; mode: integer): integer; c;
function _p_paramcount: integer; c;
function _p_paramstr(num: integer; var str: string): Boolean; c;
function rename(old: __cstring__; new: __cstring__): integer; c;
function rmdir(path: __cstring__): integer; c;
function MapUnixErrorToDosError(ErrorOccured: integer): integer;
const
EPERM = 1; { Not super-user }
ENOENT = 2; { No such file or directory }
EACCES = 13; { Permission denied }
EBUSY = 16; { Mount device busy }
EEXIST = 17; { File exists }
ENOTDIR = 20; { Not a directory }
ENOSPC = 28; { No space left on device }
EROFS = 30; { Read only file system }
EMLINK = 31; { Too many links }
ENAMETOOLONG= 91; { File or path name too long }
var
Result: integer;
UnixError: integer;
begin
if ErrorOccured
then begin
UnixError := EACCES; { should be errno... }
case UnixError of
ENOENT : Result := 2;
ENOTDIR : Result := 3;
EPERM,
EACCES,
EEXIST,
ENOSPC,
EROFS,
EMLINK,
ENAMETOOLONG: Result := 5;
EBUSY : Result := 152;
otherwise
Result := UnixError;
end; { case }
end
else begin
Result := 0;
end;
MapUnixErrorToDosError := Result;
end; { MapUnixErrorToDosError }
{ the system routines itself }
procedure Assign;
var
b : BindingType;
begin
unbind(t);
b := binding(t);
b.Name := Name;
bind(t, b);
b := binding(t);
end;
procedure BPChDir(s: string);
begin
InOutRes := MapUnixErrorToDosError(chdir(s));
end; { ChDir }
procedure Close;
begin
unbind(t);
end;
function Copy;
begin
if Index+Count > length(s)
then Copy := SubStr(s, Index)
else Copy := SubStr(s, Index, Count);
end;
procedure Dec;
begin
i := i - 1;
end;
procedure Delete;
begin
if Index = 1
then begin
if 1+Count > length(s)
then s := ''
else s := s[1+Count..length(s)];
end
else begin
if Index+Count > length(s)
then s := s[1..Index-1]
else s := s[1..Index-1] + SubStr(s, Index+Count);
end;
end;
procedure Erase;
var
bt: BindingType;
begin
bt := Binding(f);
unbind(f);
InOutRes := MapUnixErrorToDosError(unlink(bt.name));
end;
procedure GetDir(D: byte; var s: string);
var
Buffer: TPath;
pc: PChar;
i: integer;
begin
pc := getcwd(Buffer, MaxPath);
s := '';
i := 0;
while pc[i] <> Chr(0) do begin
s := s + pc[i];
i := i + 1;
end;
{ call to StrPas does not work????
s := StrPas(pc);}
end; { GetDir }
procedure Inc;
begin
i := i + 1;
end;
function IOResult : integer;
begin
IOResult := InOutRes;
InOutRes := 0;
end;
function MaxAvail;
begin
MaxAvail := MaxInt;
end;
function MemAvail;
begin
MemAvail := MaxInt;
end;
procedure BPMkDir;
begin
InOutRes := MapUnixErrorToDosError(mkdir(s, 8#0700));
end; { BPMkDir }
function ParamCount;
begin
ParamCount := _p_paramcount - 1;
end; { ParamCount }
function ParamStr;
var
Str : string255;
Success: Boolean;
begin
Success := _p_paramstr(Index, Str);
if Success
then
ParamStr := Str
else
ParamStr := '';
end; { ParamStr }
procedure BPRename;
var
bt: BindingType;
begin
bt := Binding(f);
unbind(f);
InOutRes := MapUnixErrorToDosError(rename(bt.name, Newname));
bt.Name := Newname;
bind(f, bt);
end; { BPRename }
procedure BPRmDir;
begin
InOutRes := MapUnixErrorToDosError(rmdir(s));
end; { RmDir }
function UpCase;
begin
if Ch in ['a'..'z']
then UpCase := Chr(Ord('A') + (Ord(Ch) - Ord('a')))
else UpCase := Ch;
end;
{ we need an initialization section because gpc doesn't yet have
initialized variables }
to begin do
begin
{HeapError := nil;}
InOutRes := 0;
end;
end.
[View Less]
Here a small program which 'demonstrates' the use of the system.pas unit.
-------------------------test.pas------------------------
#include "system.pas"
program Test(Output);
import
System;
var
f: text;
path: string(1024);
i: integer;
begin
Assign(f, 'tmp.tmp');
Erase(f);
writeln('IOResult = ', IOResult);
Assign(f, 'q.pas.bak');
BPRename(f, 'renamed.file');
writeln('IOResult = ', IOResult);
GetDir(0, path);
writeln('Current dir = ', path);
BPMkDir('mydir');
…
[View More]writeln('IOResult = ', IOResult);
BPRmDir('mydir');
writeln('IOResult = ', IOResult);
writeln('ParamCount = ', ParamCount);
for i := 1 to ParamCount do begin
writeln('parameter ', i, ' = ', ParamStr(i));
end;
end.
-------------------------test.pas------------------------
Groetjes,
Berend. (-:
[View Less]