AddImage (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
 
(30 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Template:Stringlist:AddImage subtitle}}
{{Template:Stringlist:AddImage subtitle}}


This callable method copies data from an image to a Stringlist. The AddImage method accepts one argument and returns a numeric result.
This [[Notation conventions for methods#Callable functions|callable]] method copies data from an image to a <var>Stringlist</var>. The <var>AddImage</var> method accepts one argument and returns a numeric result.
 
AddImage is a member of the [[Stringlist class]].


==Syntax==
==Syntax==
Line 9: Line 7:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%rc</th>
<tr><th>%number</th>
<td>A numeric variable to contain the number of items in the indicated Stringlist after the string has been added to the Stringlist. '''%rc''' is also the item number associated with the added string in the Stringlist.</td></tr>
<td>A numeric variable to contain the number of items in the indicated <var>Stringlist</var> after the string has been added to the <var>Stringlist</var>. <var class="term">%number</var> is also the item number associated with the added string in the <var>Stringlist</var>.</td></tr>
<tr><th>sl</th>
<tr><th>sl</th>
<td>A Stringlist object.</td></tr>
<td>A <var>Stringlist</var> object.</td></tr>
<tr><th>imagename</th>
<tr><th>imageName</th>
<td>A string that contains the name of an image or of any image item from the required image. This argument is optional if an image has been associated with the Stringlist by a [[BindImage (Stringlist function)]]. Otherwise, it is a required argument.</td></tr>
<td>A string that contains the name of an image or of any image item from the required image. This argument is optional if an image has been associated with the <var>Stringlist</var> by a <var>[[BindImage (Stringlist function)|BindImage]]</var>. Otherwise, it is a required argument.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
 
<ul><li>All errors result in request cancellation.</ul>
All errors result in request cancellation.


==Examples==
==Examples==
The following example demonstrates how AddImage might be used:
<ol><li>The following example demonstrates how <var>AddImage</var> might be used:


<pre>
<p class="code">image cust
image cust
  name is string len 20
name is string len 20
  ssn is string len 10
ssn is string len 10
  bdate is string len 8
bdate is string len 8
end image
end image
...
...
find records to %recset
find records to %recset
name = smith
  name = smith
end find
end find
...
...
Line 39: Line 35:


for each record in %recset
for each record in %recset
%cust:name = name
  %cust:name = name
%cust:ssn = ssn
  %cust:ssn = ssn
%cust:bdate = bdate
  %cust:bdate = bdate
%count = %list:addImage('CUST')
  %count = %list:addImage('CUST')
end for
end for
</pre>
</p>
 
<li>A more efficient way of coding the <var>For Each Record</var> loop is:
A more efficient way of coding the For Each Record Loop is:
<p class="code">%list:bindImage('CUST')
 
<pre>
%list:bindImage('CUST')
for each record in %recset
for each record in %recset
%cust:name = name
  %cust:name = name
%cust:ssn = ssn
  %cust:ssn = ssn
%cust:bdate = bdate
  %cust:bdate = bdate
%count = %list:addImage
  %count = %list:addImage
end for
end for
</pre>
</p>
 
In this last example, the <var>[[BindImage (Stringlist function)|BindImage]]</var> associates the image with the <var>Stringlist</var>, eliminating the need to specify the image name on the <var>AddImage</var> invocation.</ol>
In this last example, the [[BindImage (Stringlist function)]] associates the image with the Stringlist, eliminating the need to specify the image name on the AddImage invocation.


[[Category:Stringlist methods|Addimage function]]
==See also==
{{Template:Stringlist:AddImage footer}}

Latest revision as of 19:40, 14 July 2011

Add image as new Stringlist item (Stringlist class)


This callable method copies data from an image to a Stringlist. The AddImage method accepts one argument and returns a numeric result.

Syntax

[%number =] sl:AddImage[( [imageName])]

Syntax terms

%number A numeric variable to contain the number of items in the indicated Stringlist after the string has been added to the Stringlist. %number is also the item number associated with the added string in the Stringlist.
sl A Stringlist object.
imageName A string that contains the name of an image or of any image item from the required image. This argument is optional if an image has been associated with the Stringlist by a BindImage. Otherwise, it is a required argument.

Usage notes

  • All errors result in request cancellation.

Examples

  1. The following example demonstrates how AddImage might be used:

    image cust name is string len 20 ssn is string len 10 bdate is string len 8 end image ... find records to %recset name = smith end find ... %list is object stringList %list = new for each record in %recset %cust:name = name %cust:ssn = ssn %cust:bdate = bdate %count = %list:addImage('CUST') end for

  2. A more efficient way of coding the For Each Record loop is:

    %list:bindImage('CUST') for each record in %recset %cust:name = name %cust:ssn = ssn %cust:bdate = bdate %count = %list:addImage end for

    In this last example, the BindImage associates the image with the Stringlist, eliminating the need to specify the image name on the AddImage invocation.

See also