Cache object creation(How to get a input to user)
Below object creation is correct or not .Suppose wrong as how to get the values to user.
Set Name=##class(Example.Team1).%New()
r "enter your name :",Name.EmpName.
r "enter your address:",Name.Address
r "Enter your Phone number:",Name.PhoneNo
r "Enter Your Id:",Name.id
set status = Name.%Save()
You can only read into simple local variables, so it should be like:
set Name=##class(Example.Team1).%New() read "enter your name :", NameStr set Name.EmpName = NameStr
There are also utility prompt methods, see %Library.Prompt class. For example GetString method supports object properties:
set Name=##class(Example.Team1).%New() do ##class(%Library.Prompt).GetString("enter your name", Name.EmpName)
Thanks
The code you supplied above doesn't compile correctly in Studio, so it looks like you can't read directly to a property of an object directly. In your case, I would try something like this:
read "Enter your name: ",nameinput
set Name.Name = nameinput
set status = Name.%Save()
There may be other ways of getting input into an object property, but this is one of the easiest.
Thanks