Currently, many information systems are based on the B/S version, but Pb-written information systems have a large living space. Generally, an information system has a PB version and a B/S version. There are many business rules in the Information System. The check of business rules in B/S is implemented in JavaScript scripts. If it is implemented again in Pb, it takes time and effort to avoid it,
Changing Business Rules requires re-compilation and distribution. If the Javascript script implemented in B/S is called in Pb to complete the business rules, saving time and effort and reducing the maintenance workload, let's implement it.
I. Environment Description
The msscript. ocx component is required to run the script language in Pb. The object in the registry is msscriptcontrol. scriptcontrol.
Run regedit.exe to check whether it already exists. If not, download one. Do not forget to register it!
2. Statement in Pb
Oleobject io_script
Io_script = create oleobject
Long ll_1 = io_script.connecttonewobject ("msscriptcontrol. scriptcontrol ")
If ll_1 <> 0 then
MessageBox ('hprompt ', 'create msscriptcontrol. scriptcontrol object error, please register msscript. ocx ')
Return-1
End if
3. Load JS files
Li_file = fileopen (gs_currentpath + "check. js ")
If li_file =-1 then
Return-1
End if
Li_readline = fileread (li_file, ls_1)
Do While li_readline>-1
Ls_js = ls_js + ls_1 + '~ R ~ N'
Li_readline = fileread (li_file, ls_1)
Loop
Fileclose (li_file)
Io_script.language = "jscript"
Io_script.addcode (ls_js)
4. Call functions in JS
Any la_1 = io_script.run ("checkfile", ls_filename)
Checkfile is a function in JS, and ls_filename is a parameter of the checkfile function.
What are you waiting for? Try it now !!