/
calc
69 lines (59 loc) · 2.1 KB
/
calc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
__NAME__ purpose
evaluate the enclosed arithmetic expression or Perl block
__END__
__NAME__ synopsis
&ROW_INTERPOLATE_1;
&ROW_REPARSE_1;
__END__
__NAME__ see also
calc, mvasp, perl
__END__
__NAME__ description
The tag evaluates the enclosed arithmetic expression or a &PERL; block.
The last expression evaluated (return value) is returned to the client
page.
</para><para>
Note that Perl blocks can be of arbitrary content and complexity, and there
really are no typical examples to show.
__END__
TODO note about safe, note about doc on Perl programming within IC
__NAME__ notes
<!-- if you change this, also change the same in refs/perl -->
The &tag-calc; tag is lower-overhead variant of &tag-perl;, because it
does not accept arguments, does not try to interpolate tag body (well,
&tag-calcn; tag only) , does not
pre-open any database tables, and it doesn't do any extra wrapping.
</para><para>
The &tag-calc; tag will remember variable values inside the page, so you
can do the equivalent of a memory store and memory recall for a loop. In
other words, variables you initialize or set in one &tag-calc; block are
also visible in all further &tag-calc; blocks on the same page.
</para><para>
There is no reason to ever use this tag inside &tag-perl; or &tag-mvasp;.
</para><para>
&tag-calc; and &tag-perl; are the two tags that play major role in any
&PERL; programming within &IC;.
__END__
__NAME__ example: Simple Perl code, a random arithmetic expression
<programlisting>
Current magic number is: [calc]2+rand[/calc]
</programlisting>
__END__
__NAME__ example: Retrieving an Interchange session value
<programlisting>
Welcome, your user name is [calc]$Tag->data(qw/session username/)[/calc]
</programlisting>
__END__
__NAME__ example: Setting and displaying a value
<programlisting>
Order number is:
[calc] $Session->{mv_order_number} = $Values->{mv_order_number} [/calc]
</programlisting>
__END__
__NAME__ example: Clearing the return value
You can clear the return value (that is, return nothing) by simply calling
<code>return</code> with no arguments:
<programlisting>
[calc] my $a = 5; return [/calc]
</programlisting>
__END__