22.04.2013 Views

GAMS Data Exchange API

GAMS Data Exchange API

GAMS Data Exchange API

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example 1<br />

Page 12<br />

Sets<br />

i canning plants / seattle, san-diego /<br />

j markets / new-york, chicago, topeka / ;<br />

Example 1 in Delphi<br />

Please note that the Delphi program also has been written in VB.NET; see VB.NET Example ( see Example 4: VB.NET<br />

program, page 19).<br />

program example1;<br />

///////////////////////////////////////////////////////////////<br />

// This program generates demand data for a modified version //<br />

// of the trnsport model or reads the solution back from a //<br />

// gdx file. //<br />

// //<br />

// Calling convention: //<br />

// Case 1: //<br />

// Parameter 1: <strong>GAMS</strong> system directory //<br />

// The program creates a GDX file with demand data //<br />

// Case 2: //<br />

// Parameter 1: <strong>GAMS</strong> system directory //<br />

// Parameter 2: gdxfile //<br />

// The program reads the solution from the GDX file //<br />

// Paul van der Eijk Jun-12, 2002 //<br />

///////////////////////////////////////////////////////////////<br />

{$APPTYPE CONSOLE}<br />

{$H- short strings}<br />

uses<br />

sysutils,<br />

gxdefs,<br />

gmsspecs,<br />

gdxdcpdef;<br />

procedure ReportGDXError(PGX: PGXFile);<br />

var<br />

S: ShortString;<br />

begin<br />

WriteLn('**** Fatal GDX Error');<br />

GDXErrorStr(nil, GDXGetLastError(PGX),S);<br />

WriteLn('**** ',S);<br />

Halt(1);<br />

end;<br />

procedure ReportIOError(N: integer);<br />

begin<br />

WriteLn('**** Fatal I/O Error = ',N);<br />

Halt(1);<br />

end;<br />

var<br />

PGX : PGXFile;<br />

procedure Write<strong>Data</strong>(const s: string; V: double);<br />

var<br />

Indx : TgdxStrIndex;<br />

Values: TgdxValues;<br />

begin<br />

Indx[1] := s;<br />

Values[vallevel] := V;<br />

GDX<strong>Data</strong>WriteStr(PGX,Indx,Values);<br />

end;<br />

var<br />

Msg : string;<br />

GDX <strong>GAMS</strong> <strong>Data</strong> <strong>Exchange</strong> Example<br />

programs<br />

<strong>GAMS</strong> <strong>Data</strong> <strong>Exchange</strong> <strong>API</strong><br />

1.6<br />

Page 12 2.4<br />

12/3/2012

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!