$title Menu Selection at Execution Time From a GAMS Program

* Install select.gms and select.vbs in your GAMS libinclude directory

set	i	Set of Options /apples, pears, bannanas/,
	j(*)	Define the default selection /pears/;

$libinclude select i j

display "Selected value is:",j;

A screen shot.

----     36 Selected value is:

----     36 SET j  Define the default selection


* This example requires that you install html2gms.vbs in your GAMS libinclude directory

$title Illustrate how to use html2gms.vbs * Define a form with some checkboxes and selection fields. * The names used in checkbox are "global". The option names * used for each selection are local to that selection. $onecho >form.html <html><script language=vbs>bWait=true</script> <body bgColor=Silver><center> <b>We first select the set of foods (f):<b><p> <input type=checkbox CHECKED name="mushrooms" >mushrooms<BR> <INPUT TYPE=CHECKBOX NAME="greenpeppers">green peppers<BR> <INPUT TYPE=CHECKBOX NAME="olives">olives<BR> <INPUT TYPE=CHECKBOX NAME="onions">onions<P> <b>We then select one or more drinks to have with dinner:<b><p> <select name=d multiple> <option selected>wine</option> <option selected>water</option> <option>beer</option> <option>bugjuice</option></select><p> <b>We finally a single most preferred drinks:<b><p> <select name=m> <option selected>wine</option> <option>beer</option> <option>vodka</option></select><p> <button id=but0 onclick='bWait=false'>OK</button></center> </body></html> $offecho set foods /mushrooms,greenpepers,olives,onions,rice/, drinks /wine,water,beer,bugjuice,vodka/; * Illustrate execution time invocation: set f(foods) Selected foods, d(drinks) Selected drinks m(drinks) Most preferred * Define a temporary directory to hold the GDX file: $set tmpdir %gams.scrdir% * Invoke the script from the GAMS system directory with a window * width of 500 and height of 400: execute 'cscript "%gams.ldir%html2gms.vbs" form /d:"%tmpdir%" /w:400 /h:500'; execute 'gams "%tmpdir%htmldata" o="%tmpdir%htmldata.lst" gdx="%tmpdir%htmldata.gdx"'; execute_load "%tmpdir%htmldata.gdx", f=checked, d, m; execute 'rm -f %tmpdir%htmldata.*'; display f,d,m;
---- 51 SET f Selected foods mushrooms, onions ---- 51 SET d Selected drinks wine , water ---- 51 SET m Most preferred wine