BindImage (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (camelCase)
m (usage notes)
Line 24: Line 24:
<li><var>[[SortNew (Stringlist function)|SortNew]]</var>
<li><var>[[SortNew (Stringlist function)|SortNew]]</var>
</ul>
</ul>
 
<li>The association between an image and a <var>Stringlist</var> is generally used when all <var>Stringlist</var> items have the same layout as the image. Methods that create a new <var>Stringlist</var> usually propagate the image binding from the method <var>Stringlist</var> to the output <var>Stringlist</var>.</ul>
The association between an image and a <var>Stringlist</var> is generally used when all <var>Stringlist</var> items have the same layout as the image. Methods that create a new <var>Stringlist</var> usually propagate the image binding from the method <var>Stringlist</var> to the output <var>Stringlist</var>.</ul>


==Examples==
==Examples==
Line 33: Line 32:


<p class="code">%list is object stringList
<p class="code">%list is object stringList
...
  ...
image customer
image customer
   id is string len 8
   id is string len 8
   lname is string len 32
   lname is string len 32
end image
end image
...
  ...
%list = new
%list = new
%list:bindImage('CUSTOMER')
%list:bindImage('CUSTOMER')
...
  ...
for each record in %recset
for each record in %recset
   %customer:id = id
   %customer:id = id
Line 52: Line 51:


<p class="code">%list is object stringList
<p class="code">%list is object stringList
...
  ...
image customer
image customer
   id is string len 8
   id is string len 8
   lname is string len 32
   lname is string len 32
end image
end image
...
  ...
%list = new
%list = new
%list:bindImage('CUSTOMER')
%list:bindImage('CUSTOMER')
...
  ...
%list:sort('LNAME,A ID,D')
%list:sort('LNAME,A ID,D')
</p>
</p>
Line 67: Line 66:


<p class="code">%list is object stringList
<p class="code">%list is object stringList
...
  ...
image customer
image customer
   id is string len 8
   id is string len 8
   lname is string len 32
   lname is string len 32
end image
end image
...
  ...
%list = new('CUSTOMER')
%list = new('CUSTOMER')
</p>
</p>

Revision as of 01:00, 27 January 2011

Associate a Stringlist with an image (Stringlist class)


This method associates or binds an image to a Stringlist. BindImage is a subroutine that accepts one argument, an image name, and does not return anything.

Syntax

sl:BindImage( imageName)

Syntax terms

sl A Stringlist object.
imageName A string that contains the name of an image. This argument is case sensitive. That is, in the likely event the User Language was written in mixed case, with automatic upper-casing in effect, the image name should be in uppercase.

Usage notes

  • All errors in BindImage result in request cancellation.
  • These methods can use the association between an image and a Stringlist:
  • The association between an image and a Stringlist is generally used when all Stringlist items have the same layout as the image. Methods that create a new Stringlist usually propagate the image binding from the method Stringlist to the output Stringlist.

Examples

  1. Once an image is bound to a Stringlist, methods that operate on an image can omit the image name parameter. This is not only convenient from a coding perspective, it is more efficient -- no image name lookup needs to be done in NTBL. The following example illustrates such a use of BindImage:

    %list is object stringList ... image customer id is string len 8 lname is string len 32 end image ... %list = new %list:bindImage('CUSTOMER') ... for each record in %recset %customer:id = id %customer:lname = lname %list:addImage end for

  2. BindImage could also enable the Sort and SortNew methods to use the names of image items in the sort criteria rather than column numbers, for example, where a Stringlist has a layout described by an image:

    %list is object stringList ... image customer id is string len 8 lname is string len 32 end image ... %list = new %list:bindImage('CUSTOMER') ... %list:sort('LNAME,A ID,D')

  3. It is probably quite common that one and only one image is bound to a Stringlist in a request. In such cases, the BindImage functionality can be achieved with the New method by using an image name argument on the method invocation:

    %list is object stringList ... image customer id is string len 8 lname is string len 32 end image ... %list = new('CUSTOMER')

See also