Subject: | |
From: | |
Reply To: | |
Date: | Sat, 18 Oct 1997 17:48:40 EDT |
Content-Type: | multipart/mixed |
Parts/Attachments: |
|
|
Hi there, Pascal gurus!
I am trying to learn the module extensions of HP Pascal, prior to porting
some code from Delphi into Pascal/iX. I'm having trouble getting the module
thingies to work!
I define in source file A: (Also attached as demomod)
Module demomod;
00001000
00002000
EXPORT
00003000
00004000
Type
00005000
PWidget = ^TWidget;
00006000
alfa = packed array [0..15] of char;
00007000
00008000
Procedure NameWidget( Widget : PWidget;
00009000
var Name : alfa);
00010000
00011000
IMPLEMENT
00012000
00013000
Type
00014000
TWidget = packed record
00015000
name: alfa;
00016000
end;
00017000
00018000
Procedure NameWidget( Widget : PWidget;
00019000
var Name : alfa);
00020000
00021000
Begin
00022000
Widget^.Name:=name;
00023000
End;
00024000
00025000
End {Demomod}.
00026000
It doesn't do much, just sets the field called name to the passed in value.
Then I define in another source file (B):
Program testmod (Input, Output);
00001000
00002000
$SEARCH 'demomodo' $
00003000
00004000
Import demomod
00005000
00006000
Var
00007000
00008000
W : PWidget;
00009000
n : alfa;
00010000
s : string;
00011000
00012000
Begin {testmod}
00013000
00014000
Writeln('TESTMOD - Test use of modules in HP Pascal');
00015000
00016000
Writeln('Creating new variables for widget');
00017000
New (W);
00018000
00019000
Writeln('Initialize name');
00020000
s:='TEST WIDGET NAME';
00021000
{0123456789ABCDEF}
00022000
n:=s;
00023000
NameWidget (W, n);
00024000
00025000
Writeln('Back from naming widget!');
00026000
writeln('Value of name is :',W^.name,':');
00027000
00028000
00029000
End.
00030000
Questions:
1) I believe the syntax for the New (W) statement is accurate (it matches
the examples in the manual)
2) After the import statement, I get an error message saying "Missing ';'
(0626)". Which leads me to believe that the import statement is failing. Yet
when I dump the object file from the compiled DEMOMOD (hich is in demomodo),
the module text seems to be all there. However, the only part which shows up
on my listing is the last 13 characters or so:
ALFA ) ; end;
3) The compiler swears at me that I am invaldily dereferencing an imported
pointer, and yet the pointer is actually created in the main program (only
the type definition is imported).
My expectation was that I'd be able to define a nice opaque type (Widget)
and be able to do neat stuff to it without having to worry about the actual
structure. Of course, I also want to be able to get at the structure when I
want to!
This feels very reminiscent of some experiences I've had with MickeySoft -
and I don't like it! Can anyone explain what particularly dumb things I'm
doing? I'd like to do this next project in Pascal rather than recoding it
into a useful language (like COBOL ;-) ;-)
TIA
TOny
Module demomod; 00001000
00002000
EXPORT 00003000
00004000
Type 00005000
PWidget = ^TWidget; 00006000
alfa = packed array [0..15] of char; 00007000
00008000
Procedure NameWidget( Widget : PWidget; 00009000
var Name : alfa); 00010000
00011000
IMPLEMENT 00012000
00013000
Type 00014000
TWidget = packed record 00015000
name: alfa; 00016000
end; 00017000
00018000
Procedure NameWidget( Widget : PWidget; 00019000
var Name : alfa); 00020000
00021000
Begin 00022000
Widget^.Name:=name; 00023000
End; 00024000
00025000
End {Demomod}. 00026000
Program testmod (Input, Output); 00001000
00002000
$SEARCH 'demomodo' $ 00003000
00004000
Import demomod 00005000
00006000
Var 00007000
00008000
W : PWidget; 00009000
n : alfa; 00010000
s : string; 00011000
00012000
Begin {testmod} 00013000
00014000
Writeln('TESTMOD - Test use of modules in HP Pascal'); 00015000
00016000
Writeln('Creating new variables for widget'); 00017000
New (W); 00018000
00019000
Writeln('Initialize name'); 00020000
s:='TEST WIDGET NAME'; 00021000
{0123456789ABCDEF} 00022000
n:=s; 00023000
NameWidget (W, n); 00024000
00025000
Writeln('Back from naming widget!'); 00026000
writeln('Value of name is :',W^.name,':'); 00027000
00028000
00029000
End. 00030000
|
|
|