For integrate submit JCL and compile with Vim, we need some pre-works:
1. One shell script: use ftp and site command to submit JCL to jes, we call it ftpwj.sh, JCL file name is passed as parameter.
2. One shell script: generate JCL for compile programs, the compile mode and program name can be passed to shell as parameters. We call it comp2jes.sh
Use shc compile the two scripts to executable files, and move them to folder which in $PATH.
Now we can use vim's scirpt to call these executable files to submit JCL or compile programs:
Submit JCL:
1 function ! SubmitJCL( ... ) "{{{
2 if &ft== "jcl"
3 let s:sourceFile= substitute ( expand ( "%" ) ," // " ,"/" ,"g" )
4 else
5 echohl ErrorMsg | echo "Not a JCL file" | echohl NONE
6 return
7 endif
8 if a:0 == 1
9 let s:siteSys= a:1
10 if s:siteSys== "w"
11 exec "silent !ftpwj put " . s:sourceFile
12 elseif s:siteSys== "q"
13 exec "silent !ftpqj put " . s:sourceFile
14 endif
15 else
16 exec "silent !ftpwj put " . s:sourceFile
17 endif
18 endfunction "}}}
JCL file is the parameter passed to function SubmitJCL and then passed to ftpwj.exe, ftpwj.exe will put it to JES.
ftpqj is another application like ftpwj, they can send JCL to diffrent server.
Compile programs:
20 function ! CompFile( ... ) "{{{
21 if &ft== "pli"
22 let s:sourceFile= substitute ( expand ( "%" ) ," // " ,"/" ,"g" )
23 else
24 echohl ErrorMsg | echo "Not a source file" | echohl NONE
25 return
26 endif
27 if a:0 == 1
28 let s:sourceType= a:1
29 call FtpMput ()
30 if s:sourceType== "bat"
31 exec "!comp2jes " . s:sourceFile. " BAT"
32 elseif s:sourceType== "onl"
33 exec "!comp2jes " . s:sourceFile. " ONL"
34 endif
35 else
36 echohl ErrorMsg | echo "Parameter needed" | echohl NONE
37 endif
38 endfunction "}}}
BAT or ONL is the compilation mode as parm transfer to comp2jes.
Program name also is one parm. Here call FtpMput function to transfer source to server then compile.