Example on how to use savecolumn and restore column commands

The attached spec SAVE_RESTORE_COLUMNS.QPX is an example showing how to use the “save_column” and “restore_column” commands so you can have a column free “real” data area that will be delivered to clients and a column free “work” data area that will not be delivered by clients.

Look at the .CHK file that is created to see what the data layout for this would be.

The first part of this example is using a long hand approach to setting this up while the 2nd part is using the filetodb and define commands to substantially reduce the amount of typing required.

>purgesame~Prep compile[saverestore,WorkStart=401,TextStart=501]'This example assumes that the first piece of data does NOT want to be in the real data.  As soon as you come to the first piece then do a Savecolumn to store off the current data position, then use the !column command to set the first column in your "work" free area. This must be below your true workstart if you have one, or below your textstart if you don't have a workstart. {!SaveColumn A } {!Column 201 } { WORK1:This is work question 1!Variable,,2 }'Anytime you want to then switch to put data into the real area, then use the savecolumn command to save the current data position in the work are and then use the restorecolumn to get back to the location pointer you had in the real data.{!SaveColumn W }{!RestoreColumn A }>Repeat $A=1,...,5{ REAL$A:This is Real Question $A!Variable }>EndRepeat { REALTX1:A Real Text Question!Text } ''Anytime you want to then switch to put data into the work area, then use the savecolumn command to save 'the current data position for the real data and then use the restorecolumn to get back to the location pointer 'you had in the work data. {!SaveColumn A }{!RestoreColumn W }>Repeat $A=2,3{ WORK$A:This is Work Column $A!Variable,,3 }>EndRepeat { WORKWORK: 401This question is in the True Work Area!Variable,,20 } { WORK4:This is Work Column 4!Variable,,2 } {!SaveColumn W }{!RestoreColumn A }>Repeat $A=6,7,8{ REAL$A:This is Real Column $A!Variable,,2 }>EndRepeat {!SaveColumn A }{!RestoreColumn W } { LASTWORK:This is The Last Work Question!Variable,,10 }~CommentThis example expounds on the first example, in that it shows how to use the >filetodb command and a >def to substantially reduce the amount of text that is needed to switch back and forth between the two data areas.  You could even decide to change the name on your defines to be single letters like r and w so that it you only need to type @r or @W to switch back and forth".>filetodb Workdata #{!SaveColumn A }{!RestoreColumn W }>Eof>filetodb Realdata #{!SaveColumn W }{!RestoreColumn A }>Eof>Define @WorkData &&Workdata>Define @RealData &&RealData>Define @WorkDataStart 201>purgesame~Prep compile[wkcf2,WorkStart=401,TextStart=501] {!SaveColumn A }{!Column @WorkDataStart } { WORK1:This is work question 1!Variable,,2 }@Realdata>Repeat $A=1,...,5{ REAL$A:This is Real Question $A!Variable }>EndRepeat { REALTX1:A Real Text Question!Text }@WorkData>Repeat $A=2,3{ WORK$A:This is Work Column $A!Variable,,3 }>EndRepeat { WORKWORK: 401This question is in the True Work Area!Variable,,20 }{ WORK4:This is Work Column 4!Variable,,2 }@RealData>Repeat $A=6,7,8{ REAL$A:This is Real Column $A!Variable,,2 }>EndRepeat@WorkData { LASTWORK:This is The Last Work Question!Variable,,10 }~End

  • save_restore_columns.qpx