Value (ScreenField property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax table to syntax template; edits, tags and links)
Line 1: Line 1:
{{Template:ScreenField:Value subtitle}}
{{Template:ScreenField:Value subtitle}}
The <var>Value</var> property sets or returns the value of a <var>ScreenField</var>. The value is set from or copied to a User Language string, and it may be from 0-255 characters in length.


This property sets or returns the value of a ScreenField. The value is set from or copied to a User Language string, and it may be from 0-255 characters in length.
==Syntax==
==Syntax==
{{Template:ScreenField:Value syntax}}
{{Template:ScreenField:Value syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%sfield</th>
<tr><th>%currentString</th>
<td>A reference to an instance of a ScreenField object. </td></tr>
<td>A User Language string variable to contain the returned <var class="term">sfield</var> data.</td></tr>
<tr><th>newvalue</th>
<tr><th>sfield</th>
<td>The string value to assign to %sfield. </td></tr>
<td>A reference to an instance of a <var>ScreenField</var> object. </td></tr>
<tr><th>%string</th>
<tr><th>newString</th>
<td>A User Language string variable to contain the returned %sfield data.</td></tr>
<td>The string value to assign to <var class="term">sfield</var>. </td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul><li>After <var>[[Read_(Screen_function)|Read]]</var>ing a <var>Screen</var> object, you use the <var>Value</var> method to get any user-entered data for a non-protected field.
<li>For an example using <var>Value</var> to set field display data, see the [[Screen_object_sample_code|"Screen object sample code"]].
<li>For an example using <var>Value</var> to get user-entered data, see the example below.
</ul>


After a Read method (&amp;#x201C;Read function&amp;#x201D; on page 904) on the Screen object, you use the Value method to get any user-entered data for a non-protected field.
==Examples==
<ol><li>In the following example, a screenfield <code>%scrfmsg</code> set up to display an error message to the user is populated according to the user command input in screenfield <code>%scrfcmd</code>.  The <var>[[$SirMsg]]</var> argument identifies the number of the line to be returned from a procedure designated by <var>[[$SirMsgP]]</var> (not shown).
<p class="code">    ...
  %scr is object screen
  %scrfmsg is object screenfield
  %scrfcmd is object screenfield
  %scrfmsg = %sscr:<var>addField</var>(row=3, column=1, -
  width=%scr:columns - 1, -
                color=red)
    ...
  %scr:read
  if %scrfcmd:value = 'x' then
      %msg = <var>$Sirmsg</var>(11)
  if %scrfcmd:value = 'y' then
      %msg = <var>$Sirmsg</var>(12)
    ...
  %scrfmsg:<var>value</var> = %msg
    ...
</p>
</li>


For an example using Value to set field display data, see &amp;#x201C;[[Screen class example]]&amp;#x201D;. For an example using Value to get user-entered data, see the example below.
See also the [[Screen class#AddField function|AddField method]], whose Value parameter can set display data when the ScreenField is instantiated.
==See also==
==See also==
<ul><li>The <var>[[Screen class#AddField function|AddField]]</var>, whose <var class="term">Value</var> parameter can set display data when the <var>ScreenField</var> is instantiated.
</ul>
{{Template:ScreenField:Value footer}}
{{Template:ScreenField:Value footer}}

Revision as of 06:13, 1 July 2011

Set or return the value of a screenfield (ScreenField class)

The Value property sets or returns the value of a ScreenField. The value is set from or copied to a User Language string, and it may be from 0-255 characters in length.

Syntax

%currentString = sfield:Value sfield:Value = newString

Syntax terms

%currentString A User Language string variable to contain the returned sfield data.
sfield A reference to an instance of a ScreenField object.
newString The string value to assign to sfield.

Usage notes

  • After Reading a Screen object, you use the Value method to get any user-entered data for a non-protected field.
  • For an example using Value to set field display data, see the "Screen object sample code".
  • For an example using Value to get user-entered data, see the example below.

Examples

  1. In the following example, a screenfield %scrfmsg set up to display an error message to the user is populated according to the user command input in screenfield %scrfcmd. The $SirMsg argument identifies the number of the line to be returned from a procedure designated by $SirMsgP (not shown).

    ... %scr is object screen %scrfmsg is object screenfield %scrfcmd is object screenfield %scrfmsg = %sscr:addField(row=3, column=1, - width=%scr:columns - 1, - color=red) ... %scr:read if %scrfcmd:value = 'x' then %msg = $Sirmsg(11) if %scrfcmd:value = 'y' then %msg = $Sirmsg(12) ... %scrfmsg:value = %msg ...

  2. See also

    • The AddField, whose Value parameter can set display data when the ScreenField is instantiated.