Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Storage Subroutine

Let's focus on the storage subroutine of myBASdatent. The user has responded to the prompts, reviewed the data, and now needs the option of storing the data. As you'll see from the next few slides, you'll store the data in the global ^PersonD.

For each person, we must generate a new unique id number, to be used as the subscript of ^PersonD. The very first time myBASdatent runs, ^PersonD doesn't exist, so we need to make sure that the first id is 1, using Increment(). This will make ^PersonD into an array similar in conceptual structure to “normal” arrays (although it's still really an ordered tree): a list of people. Each person's record is a three-piece string of their data. Here is the first section of the store subroutine:

public sub store()
' store the data
    dim yn, id, rec, ln, fn

    input "Store? (y/n): ", yn  ' see if user wants to store
    ' only go on if user says yes
    if ( yn <> "y" ) then
        println "...not stored."
        exit sub
    end if
 
    id = increment(^PersonD) ' generate a new id
    rec = name & "^" & phone & "^" & intdob ' concatenate data into a record
    ^PersonD( id ) = rec ' store the record

    ' ...remainder of store subroutine continued on next page...
end sub
Copy code to clipboard
FeedbackOpens in a new window