Skip to main content

Exercise 1: First Data Entry Class

Click here to return to the exercise description in the main part of the tutorial.

  1. Start VS Code, 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 the Terminal, and run your method, by typing do ##class(ObjectScript.DataEntry1).Main().

FeedbackOpens in a new tab