|
Local formatting |
Top Previous Next |
|
While global formatting is nice sometimes certain items require individual attention. GAMS provides item specific formatting, which overrides global format settings. For text items the syntax of this feature is as follows:
Put item:width;
While for numeric items it is
Put item:width:decimals;
The item, width, and decimals are delimited with colons as shown above. The width is length in characters and has all the characteristics for sets, numbers and text as discussed above under the global section. A zero width again causes use of the exact width. The decimals feature behaves as discussed under the global section above. Examples from putex7.gms follow
set mine abcdefghijklmnopqrstuvwxyz /a12345678901234567890 setaabcdefghijklmnopqrstuvwxyz b12345678901234567890 setbabcdefghijklmnopqrstuvwxyz small smallone/; set small(mine) /small/; scalar number regnumber /1.2356/ smallnumber /0.00000001/ largenumber /1000000000/; put 'start quoted text here $':0 'Quotedabcedeghijklmnopqrstuvwxyz':5 '$ end here'//; put 'start item explanatory text here $':4 mine.ts:22 '$ end here'/; put 'start item explanatory text here $':0 number.ts:7 '$ end here'/; put /; loop(mine, put 'start set element name here $'0 mine.tl:0 '$ end here'/;) put /; loop(mine, put 'start set element explanatory text here $':0 mine.te(mine):0 '$ end here'/;) put /; loop(mine, put 'start set element value here $':0 mine(mine):5 '$ end here for name ' mine.tl /;) put /; loop(mine, put 'start subset element value here $':0 small(mine) :0 '$ end here for name ' mine.tl /;) put /; put 'start number here $':0 number:10:2 '$ end here'/; put 'start number here $':0 number:10:4 '$ end here'/; put 'start number here $':0 number:15:4 '$ end here'/; put 'start number here $':0 number:0:4 '$ end here'/;
and the result is
start quoted text here $Quote$ end here
starabcdefghijklmnopqrstuv$ end here start item explanatory text here $regnumb$ end here
start set element naa12345678901234567890$ end here start set element nab12345678901234567890$ end here start set element nasmall$ end here
start set element explanatory text here $setaabcdefghijklmnopqrstuvwxyz$ end here start set element explanatory text here $setbabcdefghijklmnopqrstuvwxyz$ end here start set element explanatory text here $smallone$ end here
start set element value here $ YES$ end here for name a12345678901 start set element value here $ YES$ end here for name b12345678901 start set element value here $ YES$ end here for name small
start subset element value here $NO$ end here for name a12345678901 start subset element value here $NO$ end here for name b12345678901 start subset element value here $YES$ end here for name small
start number here $ 1.24$ end here start number here $ 1.2356$ end here start number here $ 1.2356$ end here start number here $1.2356$ end here
showing width and decimal adjusted labels and numbers. The zero width entries cause exact fits as in the last line. |