# Embperl Tests - Include other Embperl pages via Execute

[- $optRawInput = 1 -] [- $tst1 = '

Here is some text

' ; -]

# 1.) Include from memory

[- Execute ({input => \$tst1, mtime => 1, inputfile => 'Some text', }) ; -]

# 2.) Include from memory with some Embperl code

[- Execute ({input => \('[- @ar = (a1, b2, c3) -' . ']

[+$ar[$col]+]

'), mtime => 1, inputfile => 'table', }) ; -]

# 3.) Include from memory with passing of variables

[- $MyPackage::Interface::Var = 'Some Var' ; -] [- Execute ({input => \'

Transfer some vars [+ $Var +] !

', inputfile => 'Var', mtime => 1, 'package' => 'MyPackage::Interface', }) ; -]

# 4.) Change the variable, but not the code

[- $MyPackage::Interface::Var = 'Do it again' ; # code is the same, so give the same mtime and inputfile to avoid recompile # Note you get problems is you change the code, but did not restart the server or # change the value in mtime. So make sure if you change something also change mtime! Execute ({input => \'

Transfer some vars [+ $Var +] !

', inputfile => 'Var2', mtime => 1, 'package' => 'MyPackage::Interface', req_rec => $req_rec}) ; -]

# 5.) Use \@param to pass parameters

[- Execute ({input => \'

Use @param to transfer some data ([+ "@param" +]) !

', inputfile => 'Param', param => [1, 2, 3, 4] } ) ; -]

# 6.) Use \@param to pass parameters and return it

[- @p = ('vara', 'varb') ; -]

### $p[0] is [+ $p[0] +] and $p[1] is [+ $p[1] +]

### [- Execute ({input => \('

Got data in @param ([+ "@param" +]) !

[- $param[0] = "newA" ; $param[1] = "newB" ; -' . ']

Change data in @param to ([+ "@param" +]) !

'), inputfile => 'Param & Return', req_rec => $req_rec, param => \@p } ) ; -]

### $p[0] is now [+ $p[0] +] and $p[1] is now [+ $p[1] +]

###

# 7.) Presetup \%fdat and \@ffld

[- %myfdat = ('test' => 'value', 'fdat' => 'text') ; @myffld = sort keys %myfdat ; Execute ({input => \'

[+ $ffld[$row] +] | [+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]

', inputfile => 'fdat & ffld', req_rec => $req_rec, fdat => \%myfdat, ffld => \@myffld} ) ; -]

# 8a.) Include a file

[- Execute ('inc.htm') -]

# 8b.) Include again the same file

[- Execute ('inc.htm') -]

# 9.) Include a file and return output in a scalar

[- Execute ({inputfile => 'inc.htm', output => \$out, req_rec => $req_rec}) ; -]

### [+ $out +]

# 10.) Include inside a table

[- @a = ('m1', 'm2', 'm3') -]

[+ $a[$row] +] : [- Execute ({inputfile => 'incsub.htm', req_rec => $req_rec, param => [$a[$row], 'main']}) -]

# 11.) Include a file with parameters

[- Execute ('incparam.htm', 0, 'B', 'three', 'dddd', '555') -]

# 12.) Include a file and write outputfile

[# - Execute ({inputfile => 'inc.htm', outputfile => "../tmp/incout.htm", }) ; - #]

# 12.) Done :-)

HTML::Embperl (c) 1997-1998 G.Richter