Use Javascript script functions in Pb

Source: Internet
Author: User

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 !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.