Skip to content

Instantly share code, notes, and snippets.

@tonypdmtr

tonypdmtr/a.pas Secret

Last active April 22, 2016 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonypdmtr/cae849750376d5cc7e2028e0835e385a to your computer and use it in GitHub Desktop.
Save tonypdmtr/cae849750376d5cc7e2028e0835e385a to your computer and use it in GitHub Desktop.
Example of Pascal record with or without variant
program a;
type xxx = record
a,b,c: char;
end;
var f: file of xxx;
v: xxx;
begin
assign(f,'a.dat');
rewrite(f);
v.a := 'a';
v.b := 'b';
v.c := 'c';
write(f,v);
close(f);
end.
program b;
type xxx = record
case byte of
0: (a: char);
1: (b: char);
2: (c: char);
end;
var f: file of xxx;
v: xxx;
begin
assign(f,'b.dat');
rewrite(f);
v.a := 'a';
v.b := 'b';
v.c := 'c';
write(f,v);
close(f);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment