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.