$ProcOpn: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (misc cleanup)
Line 2: Line 2:
<span class="pageSubtitle">Open procedure for $ProcDat, $ProcGet, $ProcLoc</span>
<span class="pageSubtitle">Open procedure for $ProcDat, $ProcGet, $ProcLoc</span>


<p class="warn"><b>Note: </b>Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $ProcOpn function.</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $ProcOpn function.</p>


The <var>$ProcOpn</var> function is used to "open" a procedure as input to a <var class="product">User Language</var> procedure via <var>[[$ProcGet]]</var>, <var>[[$ProcDat]]</var> and <var>[[$ProcLoc]]</var>.  
The <var>$ProcOpn</var> function is used to "open" a procedure as input to a <var class="product">SOUL</var> procedure via <var>[[$ProcGet]]</var>, <var>[[$ProcDat]]</var>, and <var>[[$ProcLoc]]</var>.  


<var>$ProcOpn</var> accepts three arguments and returns a numeric code, and it is a [[Calling Sirius Mods $functions|callable]] $function.
<var>$ProcOpn</var> accepts three arguments and returns a numeric code. It is also a [[Calling Sirius Mods $functions|callable]] $function.


The first argument is required and identifies the <var class="product">User Language</var> procedure to be opened.
==Syntax==
<p class="syntax"><span class="term">%result</span> = <span class="literal">$ProcOpn</span>(<span class="term">proc_name</span>, [<span class="term">file_name</span>], <span class="term">inc_string</span>)
</p>


The second argument is an optional file name. If the second argument is not provided, or is a null string, the current file is used.
===Syntax terms===
<table>
<tr><th>%result</th>
<td>A numeric [[#Return codes|return code]] that indicates the success of the function.</td></tr>


The third argument is a string that is used by <var>$ProcGet</var> for dummy string substitution just as if this argument had been placed on an INCLUDE statement. Note that <var>$ProcDat</var> does no dummy string substitution.
<tr><th>proc_name</th>
<td>This argument is required; it identifies the <var class="product">SOUL</var> procedure to be opened. </td></tr>


==Syntax==
<tr><th>file_name</th>
<p class="syntax"><span class="term">%result</span> = <span class="literal">$ProcOpn</span>(<span class="term">proc_name</span>, [<span class="term">file_name</span>], <span class="term">inc_string</span>)
<td>An optional file name. If this argument is not provided or is a null string, the current file is used. </td></tr>
</p>


<p>
<tr><th>inc_string</th>
<span class="term">%result</span> is set to indicate the success of the function.</p>
<td>A string that is used by <var>$ProcGet</var> for dummy string substitution, just as if this argument had been placed on an <var>Include</var> statement.
<p class="note"><b>Note:</b> <var>$ProcDat</var> does no dummy string substitution. </p>
</table>


===Return codes===
===Return codes===
Line 25: Line 32:
  0 - Procedure opened without errors
  0 - Procedure opened without errors
  1 - Procedure is locked for edit or delete
  1 - Procedure is locked for edit or delete
  2 - Procedure does not exist or the current user does not
  2 - Procedure does not exist or the current user does not have access privilege
          have access privilege
  3 - Specified procedure name is invalid (null)
  3 - Specified procedure name is invalid (null)
  4 - File name invalid, or no current file, or caller
  4 - File name invalid, or no current file, or caller does not have sufficient  
          does not have sufficient privilege to
    privilege to display/include procedures
          display/include procedures
  5 - The maximum number of open procedures (5) has already been reached
  5 - The maximum number of open procedures (5)
  6 - Insufficient space in ITBL to hold third argument; increase the size of ITBL
          has already been reached
  6 - Insufficient space in ITBL to hold third
          argument; increase the size of ITBL
</p>
</p>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>After <var>$ProcOpn</var> has successfully opened a procedure, <var>$ProcGet</var> and <var>$ProcDat</var> may be used to retrieve the procedure source lines and <var>$ProcLoc</var> may be used to scan them.
<li>After <var>$ProcOpn</var> has successfully opened a procedure, <var>$ProcGet</var> and <var>$ProcDat</var> may be used to retrieve the procedure source lines, and <var>$ProcLoc</var> may be used to scan the lines. </li>
<li>If a 'temporary request' (a negative number or zero) is
 
specified which does not exist (this includes numbers
<li>If a "temporary request" (a negative number or zero) is
outside the range of the NORQS parameter) can produce
specified for <var class="term">proc_name</var> that does not exist (this includes numbers
an error condition. For example:
outside the range of the <var>[[NORQS parameter|NORQS]]</var> parameter), an error condition may result. For example:
   
   
<p class="code">$procOpn(-9999)
<p class="code">$procOpn(-9999)
</p>
</p>
   
   
When the above fragment is executed, the following error will occur
When the above fragment is executed, the following error occurs
(but the request continues to run):
(but the request continues to run):
   
   
<p class="code">M204.1186: Bad previous request number</p>
<p class="code">M204.1186: Bad previous request number</p>
   
   
The value <code>0</code> is returned by $ProcOpn and
The value <code>0</code> is returned by <var>$ProcOpn</var>, and
the proc treated as an empty proc. This probably
the procedure is treated as an empty procedure. This probably
works properly for applications.
works properly for most applications.
   
   
<p class="note"><b>Beware</b>, however, that if your application
<p class="note"><b>Beware:</b> If your application
passes such non-existing temporary request numbers to $ProcOpn,
passes such non-existing temporary request numbers to var>$ProcOpn</var>,
your request may be subject to request cancellation due to
your request may be subject to request cancellation due to
exceeding ERMX.</p>
exceeding <var>[[ERMX parameter|ERMX]]</var>.</p></li>
 
</ul>
</ul>


==Examples==
==Examples==
Suppose procedure TIS_PITY in procedure file HOHO contains this line:
Suppose procedure <code>TIS_PITY</code> in procedure file <code>HOHO</code> contains this line:
<p class="code">FIND1: IN ?? FIND ALL RECORDS FOR WHICH
<p class="code">FIND1: IN ?? FIND ALL RECORDS FOR WHICH
</p>
</p>
Line 81: Line 83:
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[List of $functions|Sirius functions]]
<li>[[List of $functions|Sirius functions]]
<li>[[Fast/Unload User Language Interface]]
<li>[[Fast/Unload SOUL Interface]]
<li>[[Janus Web Server]]
<li>[[Janus Web Server]]
</ul>
</ul>


[[Category:$Functions|$ProcOpn]]
[[Category:$Functions|$ProcOpn]]

Revision as of 22:06, 23 November 2016

Open procedure for $ProcDat, $ProcGet, $ProcLoc

Note: Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $ProcOpn function.

The $ProcOpn function is used to "open" a procedure as input to a SOUL procedure via $ProcGet, $ProcDat, and $ProcLoc.

$ProcOpn accepts three arguments and returns a numeric code. It is also a callable $function.

Syntax

%result = $ProcOpn(proc_name, [file_name], inc_string)

Syntax terms

%result A numeric return code that indicates the success of the function.
proc_name This argument is required; it identifies the SOUL procedure to be opened.
file_name An optional file name. If this argument is not provided or is a null string, the current file is used.
inc_string A string that is used by $ProcGet for dummy string substitution, just as if this argument had been placed on an Include statement.

Note: $ProcDat does no dummy string substitution.

Return codes

-1 - Current include level not opened by $ProcOpn 0 - Procedure opened without errors 1 - Procedure is locked for edit or delete 2 - Procedure does not exist or the current user does not have access privilege 3 - Specified procedure name is invalid (null) 4 - File name invalid, or no current file, or caller does not have sufficient privilege to display/include procedures 5 - The maximum number of open procedures (5) has already been reached 6 - Insufficient space in ITBL to hold third argument; increase the size of ITBL

Usage notes

  • After $ProcOpn has successfully opened a procedure, $ProcGet and $ProcDat may be used to retrieve the procedure source lines, and $ProcLoc may be used to scan the lines.
  • If a "temporary request" (a negative number or zero) is specified for proc_name that does not exist (this includes numbers outside the range of the NORQS parameter), an error condition may result. For example:

    $procOpn(-9999)

    When the above fragment is executed, the following error occurs (but the request continues to run):

    M204.1186: Bad previous request number

    The value 0 is returned by $ProcOpn, and the procedure is treated as an empty procedure. This probably works properly for most applications.

    Beware: If your application passes such non-existing temporary request numbers to var>$ProcOpn, your request may be subject to request cancellation due to exceeding ERMX.

Examples

Suppose procedure TIS_PITY in procedure file HOHO contains this line:

FIND1: IN ?? FIND ALL RECORDS FOR WHICH

Then this sequence:

%result = $ProcOpn('TIS_PITY', 'HOHO', ' THESE ARE ARGUMENTS') %line = $ProcGet

Results in %line being set to:

FIND1: IN THESE FIND ALL RECORDS FOR WHICH

Products authorizing $ProcOpn