docs.intersystems.com
Home  /  Application Development: Core Topics  /  ObjectScript Tutorial  /  Exercise 1: First Data Entry Class


ObjectScript Tutorial
Exercise 1: First Data Entry Class
[Back]
InterSystems: The power behind what matters   
Search:  


Click here to return to the exercise description in the main part of the tutorial.
  1. Start Atelier, and create a new class. Use ObjectScript for the package name and DataEntry1 for the class name. You'll see this code:
    Class ObjectScript.DataEntry1
    {
    
    }
    
  2. Within the {}, create the Main() method.
    Class ObjectScript.DataEntry1
    {
    
    /// first data entry method
    ClassMethod Main()
    {
        
    }
    }
    
  3. Enter the following ObjectScript into the method:
        read !, "Name: " , name
        if name = "" { quit }  // user entered nothing
        read !, "Phone: ", phone
        read !, "DOB: ", dob
    
        // display the data
        write !!!, "Name:", ?20, name
        write !, "Phone:", ?20, phone
        write !, "DOB:", ?20, dob
    
  4. Click the Save and Compile buttons.
  5. Start Terminal, and run your method, by typing do ##class(ObjectScript.DataEntry1).Main().