~Comment Sample spec file to build a Qfile which accesses an external DBfile. This allows you to enter in something like a zip code and have it go out to the DBfile and return with upto 500 characters of text. See the file EXTERNALDB.SPX to see how the DBfile is built. The DBfile will be read locally by wherever Survent is running from. For stand alone applications you just put it in the local directory, but for network/server applications you either need to make sure the interviewers all run from a standard directory (interv) and to put the file there or more likely just supply the full qualified name on the spc,9 reference. >PURGESAME ~PREP COMPILE -SPECS [EXTERNALDB,,"External DBfile Example"] {Zipcode: Type in 11111, 22222, 33333, 44444, or 55555 for a good code. Type anything else for a bad code Type a zip code (5 digits please) -->\_..... !VAR,N,5,5} {!COMMENT Append the letter X to the front of the five character zip code so that it is a valid variable name } {Xzipcode: .6 X\:Zipcode: !SPC, 9 } {!COMMENT Store the name of the DBfile into the Data } { Zdb: .35 EXTERNALDBDB ''Local Reference '/usr/cfmc/qff/exxternaldbdb ''Example Unix Reference 'F:\apps\cfmc\qff\externaldbdb ''Example DOS/Windows Reference !SPC, 9 } {Rescode: HIDE !VAR } { ZipData: .90 Hide !VAR } {!COMMENT This is the magic ZSPC code that goes out to the DBfile and returns with the appropriate text. Format of this command is ZSPC,3,4 followed by the following parameters The label name of where to store the result code. For now the result code will be either 0 (got a match in the DBfile) or E (could not find the item in the DBfile). You may also get an E if the layout of the ZSPC is wrong. The label name of where the DB items name is stored. The location of where you want to write the information retreived from the DBfile. Be sure that the length matches the amount of information you originally stored in the file. The label name of the question that holds the name of the DBfile. } { !ZSPC 3, 4, Rescode, Xzipcode, Zipdata.90 , Zdb } {!COMMENT If the result code is E then you do not have a match and may want to execute a different set of questions } {!IF [Rescode$] = "E" \A ****** \:Zipcode: is not in the list, try another one? !DISPLAY } {!COMMENT Debugging question to make sure the information is retrieved properly } { You enter \:Zipcode: This built code \|Xzipcode| Result code was \|Rescode| !DISPLAY, 2} { \A Item 1: \|Zipdata.30| Item 2: \|Zipdata+30.30| Item 3: \|Zipdata+60.30| !DISP,2 } {Last: \aLast question. Hit return to end it all !VAR } ~END