-----Original Message----- From: gpc-owner@gnu.de [mailto:gpc-owner@gnu.de]On Behalf Of CBFalconer Sent: 04 December 2001 15:12 To: gpc@gnu.de Subject: Re: Initializing variant records - how?
Martin G C Davies wrote:
I need (want!) to initialize variant records. I have created a small example - doesn't compile of course because I can't find how to do it. I guess GPC can do it since VS_Pascal (IBM/MVS), VAXPascal and
SPARCPascal all
allow me to do it (all in different ways of course!).
Anyone?
Cheers, Martin.
program varaint_test( input , output ) ;
type variant_record = record case boolean of false : ( compare : integer( 32 ) ) ; true : (
case boolean of false : ( page , offset : integer( 16 ) ) ; true : ( len , disp : integer( 16 ) ) ; ) ; end ;
var mgcd : variant_record := ( compare : 12345 ) ; (* How can I
do this? *)
begin writeln( 'ok' ) ; end.
What is wrong with the purely standard construct of:
program varaint_test( input , output ) ;
type short = -32768..32767; variant_record = record case boolean of false : ( compare : integer ) ; true : ( case boolean of false : ( page , offset : short ) ; true : ( len , disp : short ) ) ; end ;
var mgcd : variant_record;
PROCEDURE initvr(VAR r : variant_record); BEGIN r.compare := 12345; END;
begin initvr(mgcd); writeln( 'ok' ) ; end.
Of course, I just sent a small example program to demo what I want to do. What I have is a program that currently runs using the Pascal compilers mentioned above. We'd like it to run under GPC so I am trying to port it. Currently I have HUGE tables that are all compile time initialized. For sure I could rewrite the initialization to be run-time - I'm just trying to find out if GPC can actually do what I want. Having said that, thanks for the suggestion - it's certainly the best (only) suggestion so far.
Cheers, Martin.