summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/os2/perlrexx.cmd
blob: 5a32d85105404fc9709db504bf4ec72a6974bb60 (plain)
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
/* Test PERLREXX.DLL */
/* Example:
   perlrexx.cmd BEGIN {push @INC, 'lib'} use OS2::REXX; REXX_eval "address cmd\n'copyy'";
 */

call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs

parse arg args
retval = runperl(args)
say 'retval = "'retval'"'
exit 0

addperl: procedure
  parse arg perlf
  pathname='perlrexx'
  r = RxFuncAdd(perlf, pathname, perlf)
  say "RxFuncAdd("perlf","pathname") -> "r
  return

runperl1: procedure
  parse arg perlarg
  call addperl('PERL')
  call addperl('PERLTERM')
  call addperl('PERLEXIT')
  call addperl('PERLEVAL')
  call addperl('PERLLASTERROR')
  signal on syntax name runperl_error
/*  signal on error name runperl_error
  signal on failure name runperl_error */
  say "doing PERLEVAL("perlarg")"
  tmp = PERLEVAL(perlarg)
  say "PERLEVAL -> '"tmp"'"
  signal off syntax
  call RxFuncDrop 'PERL'
  call RxFuncDrop 'PERLLASTERROR'
  call RxFuncDrop 'PERLTERM'
  call RxFuncDrop 'PERLEVAL'
  call PERLEXIT
  call RxFuncDrop 'PERLEXIT'
  return pathname ': PERLEVAL('perlarg') =' tmp

runperl: procedure
  parse arg perlarg
  pathname='perlrexx'
  r = RxFuncAdd("PerlExportAll", pathname, "PERLEXPORTALL")
  say "RxFuncAdd("'PerlExportAll'","pathname") -> "r
  r = PerlExportAll()
  say "PerlExportAll() -> "r
  signal on syntax name runperl_error
/*  signal on error name runperl_error
  signal on failure name runperl_error */
  say "doing PERLEVAL("perlarg")"
  tmp = PERLEVAL(perlarg)
  say "PERLEVAL -> '"tmp"'"
  address evalperl perlarg
  say "Did address evalperl "perlarg
  signal off syntax
  r = PerlDropAllExit()
  /* The following line is not reached...  Why? */
  say "PerlDropAllExit() -> "r
  return pathname ': PERLEVAL('perlarg') =' tmp


runperl_error:
  return pathname ': REXX->Perl interface not available; rc="'rc'", .rs="'.rs'", errstr="'errortext(rc)'", perlerr="'PERLLASTERROR()'"'

/*  return pathname ': REXX->Perl interface not available; rc="'rc'", .rs="'.rs'", errstr="'errortext(rc)'", perlerr="???"' */