GetValue

Gets the value from a control.

To obtain

Use

The date and time in the Value property of the DatePicker control.

Syntax 1

The value of the key of the JSONPackage object

Syntax 2


Syntax 1: for DatePicker control

Description

Returns the date and time in the Value property of the control.

Applies to

DatePicker control

Syntax

controlname.GetValue ( d, t )
controlname.GetValue ( dt )

Argument

Description

controlname

The name of the control for which you want to get the date and time

d

The date value in the Value property returned by reference

t

The time value in the Value property returned by reference

dt

The DateTime value in the Value property returned by reference


Return value

Integer.

Returns 1 for success and one of the following negative values for failure:

-1 -- Invalid date and/or time values

-2 -- Other error

Usage

The GetValue function can return the date and time parts of the Value property in separate date and time variables or a single DateTime variable.

Examples

In this example, the GetValue function is called twice, once to return separate date and time values and once to return a DateTime value. The values returned are written to a multiline edit control:

date d
time t
datetime dt
integer li_ret1, li_ret2

li_ret1 = dp_1.GetValue(d, t)
li_ret2 = dp_1.GetValue(dt)

mle_1.text += string(d) + " ~r~n"
mle_1.text += string(t) + " ~r~n"
mle_1.text += string(dt) + " ~r~n"

See also

GetText

SetValue

Syntax 2: for JSONPackage object

Description

Gets the value of the key. The key item must be a string, object, or array.

If more than one key with the same name exists, then get the value of the first key. Notice that the IgnoreCase property (true by default) determines whether the key name will be matched in a case-sensitive manner.

Applies to

JSONPackage object

Syntax

objectname.GetValue ( Key )

Argument

Description

objectname

The name of the JSONPackage object

Key

A string specifying the key. If more than one key with the same name already exists, the value of the first key will be obtained.


Return value

String. Returns the key value if it succeeds. If any argument's value is null, the method returns null. If an error occurs, throw the exception.

Examples

This example gets data from the server and then imports the data to the DataWindow, DataStore and DataWindowChild controls:

int li_rc
string ls_JsonPackage, ls_DepartmentJson, ls_EmployeeJson, ls_DeptJson
datastore lds_employee
datawindowchild ldwc_dept
HttpClient lnv_HttpClient
JsonPackage lnv_package

lds_employee = create datastore
lds_employee.dataobject = "d_employee"

dw_employee.getchild("dept_id", ldwc_dept)

lnv_HttpClient = create HttpClient
lnv_package = create JsonPackage

// Request JSON data package from the server
li_rc = lnv_HttpClient.SendRequest("GET", "http://demo.appeon.com/PB/webapi_client/employee/102")

// Get the data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
 lnv_HttpClient.GetResponseBody(ls_JsonPackage)
 
 // Extract the JSON data package
 lnv_package.LoadString(ls_JsonPackage)
 ls_DepartmentJson = lnv_package.GetValue("d_department")
 ls_EmployeeJson = lnv_package.GetValue("d_employee")
 ls_DeptJson = lnv_package.GetValue("dddw_dept")
 
 // Import data to DataWindow, DataStore and DataWindowChild
 dw_department.ImportJson(ls_DepartmentJson)
 lds_employee.ImportJson(ls_EmployeeJson)
 ldwc_dept.ImportJson(ls_DeptJson)
end if

See also

SetValue