zoukankan      html  css  js  c++  java
  • PB代码动态解析执行器

     

    当你看到VB、VFP等开发语言提供的强大的宏执行功能,是不是很羡慕呢?当你寻遍PB的帮助、关于PB开发的书籍或网站而不可得的时候,是不是感到有一丝的遗憾?如果你看到这篇文章,你应该感到振奋,因为你终于可以解决这个问题,而且解决问题的思路既是如此简单、代码既是如此简短。如果再加上你的智慧,应该比我的解决方法更漂亮。

    先让我们来了解一些基本知识。

    一.代码的载体

    在PB中,只有三个地方可以存放代码,那就是函数、事件、属性。这里所指的函数包括有返回值的通常意义下的函数和无返回值的过程以及声明的WINAPI函数,所指的事件指在对象中定义的处理程序,所指的属性指PB系统属性之外的实例变量、共享变量、全局变量。函数和事件是可以用来调用执行的,属性则只能用来赋值和取值。通常我们是在函数或事件中编写代码。

    二.对象的创建

    如果对象类型是已知的,可以使用CREATE objecttype 来创建对象,如果对象类型是动态的,可以使用CREATE USING objecttypestring来创建对象。

    三.对象函数的调用方式

    如果调用一个已知类型的对象的函数或事件,通常采用静态模式,也可采用动态模式,如果调用一个动态创建的对象的函数或事件,则必须采用动态模式,否则编译出错。采用动态模式调用函数是在函数前加dynamic 关键字。读者可查阅PB帮助。

    四.库文件的搜索

    PB中用于编程的对象是保存在PBL、PBD、DLL中的,如果想要使库文件中的对象在应用程序运行时有效,常用的方法是直接将该PBL编译进去或者说使该PBL在库搜索列表中。如果需要在运行状态下改变库文件搜索列表,PB提供了SetLibraryList和AddToLibraryList两个函数。SetLibraryList函数只能在应用对象的open事件脚本中使用,否则应用程序会崩溃,AddToLibraryList为PB9新增的函数,用于将新文件加入到库文件搜索列表中,这两个函数都是只能在编译环境下有效。

    五.PB库文件的创建与销毁

    PB提供了LibraryCreate函数用于创建库文件,提供LibraryDelete、FileDelete函数用于删除库文件。

    六.PB实体的导入

    PB提供了LibraryImport函数用于根据对象语法创建PB实体并导入到库文件中,但该函数目前只支持数据窗口对象类型的导入。不过,PB提供了相应的WINAPI函数支持其它类型实体的导入,这些相关的WINAPI包括在PBORCX0.DLL中(不同的PB版本有不同的文件名称,如PBORC90.DLL、PBORC80.DLL)。有关实体的导入的WINAPI包括PBORCA_SessionOpen、PBORCA_SessionClose、PBORCA_SessionSetLibraryList、PBORCA_SessionSetCurrentAppl、PBORCA_CompileEntryImport等,读者可以到Sybase网站找ORCA Guide相应文章寻求支持。

    七.PB实体的查找

    使用FindClassDefinition或FindFunctionDefinition或LibraryDirectory可以在库文件中查找PB实体是否存在,使用FindClassDefinition或FindFunctionDefinition性能要好。

    以下讲开发思路。

    一.创建临时库文件
    1. 取临时目录作为库文件的存放目录
    2. 取待创建的临时库文件名称,保证不与已有文件重名
    3. 使用LibraryCreate函数创建临时库文件

    二.构造用于导入库文件的临时PB实体语法
    1. 取临时PB实体名称,保证不与库文件列表中已有PB实体重名
    2. 构造临时PB实体语法,区分函数和过程

    三.将临时PB实体导入临时库文件
    1. 取库文件列表和应用对象所在pbl
    2. 将实际不存在的库文件从库文件列表中删除,目的是使调用PBORCA_SessionSetLibraryList成功
    3. 调用PBORCA_CompileEntryImport将临时PB实体导入临时库文件

    四.将临时库文件加入到库文件搜索列表
    1. 调用AddToLibraryList加入新文件到库文件搜索列表

    五.创建临时PB实体所对应的对象并调用其函数以执行动态脚本
    1. 使用CREATE USING objecttypestring语句创建对象
    2. 通过动态调用对象的of_exec函数执行动态脚本,区分返回值类型

    六.销毁所有临时对象
    1. 调用LibraryDelete函数删除创建的临时库文件

    以下讲我在开发时遇到的一些矛盾或问题。

    一.代码是逐行解释还是让PB编译器去解释
    有些开发人员试图对动态脚本自行逐行解释,这是很困难的事情。一行代码如果脱离它的语境去执行,可能会产生错误的结果,即便你对PB所支持的函数全部做出解释,使用PB开发出来的对象、函数、事件等,你又如何去解释?这等同于你要花很大力气去编写一个PB编译器,除非你与PB编译器的开发团队合作,否则你很难获得成功。所以你必须想办法让PB编译器去解释。既然每行代码不能脱离其它代码而执行,那就创建一个函数或事件,让这个函数或事件包括你想写的所有代码。而函数或事件又不能脱离对象而存在,所以你必须想办法动态创建对象以及函数或事件,对象的声明必须依赖于库文件中的PB实体,由此推出关键是创建PB实体。

    二.如何创建PB实体
    前面已讲过要使用PBORCX0.DLL中的WINAPI函数来创建并导入实体,这项技术并不难,在sybase的网站或随便狗狗(百度)一下就能出来一大把。

    三.创建的PB实体是存放在现有库文件中还是新文件中再导入
    我最初的想法是放在现有库文件中,这样就不必花费时间在创建库文件和删除库文件的执行上,结果发现,创建是成功,但运行时PB就是不“认识”我创建的PB实体,一创建该实体的对象就报错,想来PB在程序启动时就读取库文件中有哪些实体形成列表,在没有改变库文件列表之前,其实体列表不会改变,这样对新建的实体就视而不见了。所以我不得不试着新建一个PBL,在新建的PBL中创建PB实体,然后使用AddToLibraryList将新建的PBL包括进来,这一试果然成功。

    四.使用数据窗口的Describe调用全局函数还是其它方式来取得返回值
    大家都知道,使用数据窗口的Describe函数可以调用全局函数,但是它有很多的局限性,全局函数必须有简单类型的返回值,所有参数只能是简单数据类型而且不能通过参考传值。如果在需要调用的地方直接使用新建对象的函数将不受这些限制。

    五.如何进行垃圾对象的清理
    既然每次执行动态脚本要创建PB实体,如果执行得多了,就有很多垃圾对象,所以应进行清理。可以通过LibraryDelete函数或FileDelete删除库文件。有意思的是,一旦创建PB实体,即便你删除了,使用FindClassDefinition或FindFunctionDefinition还是能够找到,但你想使用该实体创建对象则失败,这再次说明PB在程序启动时就读取库文件中有哪些实体形成列表,在没有改变库文件列表之前,其实体列表不会改变。

    以下是所附代码的几点说明

    一.所附代码是在PB9环境下开发的,程序运行时必须有PBORC90.DLL,如果改成PB其它版本,请将nvo_pbcompiler中WINAPI函数所使用的动态库做相应修改。

    二.nvo_pbcompiler用于创建PB实体,这是PB动态脚本解释器的核心函数;f_execpbscript()用于执行一段PB脚本的样例代码函数,返回值类型为字符串,如果要使用到其它场合,读者可自行编写函数,思路类似;w_pbcompiler_test为一个用来执行PB脚本的样例界面窗口;其它函数有各自功能。

    三.如果想运行PB动态脚本编译器,请先将所有代码分对象导入库文件,然后编译,PB动态脚本编译器在PB开发环境下无效。

    四.为了程序方面的简化,有些所使用的全局函数请参考作者的其它文章。

    五.所附代码仅为脚本没有参数的情况下有效,如果你想代码有参数,只需要简单地对脚本语法作些改变就可,当然前台需要用户定义参数。

    六.本PB动态脚本解释器可执行所有有效的PB代码,例如访问全局变量、使用PB所有的系统函数、使用程序员开发的自定义函数、打开窗口、访问菜单、使用数据窗口等。

    七.通常将本PB动态脚本解释器嵌入到现有的使用PB开发出来的系统而不是单独使用,这样可以加载很多免编译的外挂程序。

    八.如果再拓宽它的应用范围,你甚至可以做到只需要一个框架程序,其它代码全部动态加载和执行,这样就只需一次编译,升级和维护就变得非常简单,不过你要考虑系统的可用性、系统性能和系统的稳定性等。

    附完整源代码
    一.pbcompiler
    $PBExportHeader$pbcompiler.sra
    $PBExportComments$PB动态脚本解释器应用对象
    forward
    global type pbcompiler from application
    end type
    global transaction sqlca
    global dynamicdescriptionarea sqlda
    global dynamicstagingarea sqlsa
    global error error
    global message message
    end forward
    global variables
    end variables
    global type pbcompiler from application
    string appname = "pbcompiler"
    end type
    global pbcompiler pbcompiler
    on pbcompiler.create
    appname="pbcompiler"
    message=create message
    sqlca=create transaction
    sqlda=create dynamicdescriptionarea
    sqlsa=create dynamicstagingarea
    error=create error
    end on
    on pbcompiler.destroy
    destroy(sqlca)
    destroy(sqlda)
    destroy(sqlsa)
    destroy(error)
    destroy(message)
    end on
    event open;open(w_pbcompiler_test)
    end event
    二.f_execpbscript
    $PBExportHeader$f_execpbscript.srf
    $PBExportComments$执行动态脚本的样例函数
    global type f_execpbscript from function_object
    end type
    forward prototypes
    global function string f_execpbscript (string as_returntype, string as_pbscript)
    end prototypes
    global function string f_execpbscript (string as_returntype, string as_pbscript);/*******************************************************************
    函数名称:f_execpbscript()
    参数: as_returntype string 返回值类型
    as_pbscript string 动态代码
    返回值: string 用户自定义或错误信息
    功能描述:执行动态代码(只返回字符串)
    创建人: 康剑民
    创建日期:2007-02-12
    版本号: V1.0
    *******************************************************************/
    nvo_pbcompiler lnv_pbcompiler
    nonvisualobject luo_pbcompiler
    string ls_entryname,ls_libraryname
    string ls_return
    any la_return
    lnv_pbcompiler = create nvo_pbcompiler
    //创建实体对象
    if lnv_pbcompiler.of_createentry(as_returntype,as_pbscript,ls_libraryname,ls_entryname) = 1 then
    if not isnull(FindClassDefinition(ls_entryname) ) then
    luo_pbcompiler = create using ls_entryname
    choose case lower(as_returntype)
    case 'any','blob','boolean','char','character','date','datetime','dec','decimal','double','int','integer','long','real','string','time','uint','ulong','unsignedint','unsignedinteger','unsignedlong'
    la_return = luo_pbcompiler.dynamic of_exec()//执行动态代码
    ls_return = string(la_return)
    case '','none'
    luo_pbcompiler.dynamic of_exec()//执行动态代码
    ls_return = "none"
    case else
    luo_pbcompiler.dynamic of_exec()//执行动态代码
    ls_return = "result is disabled"
    end choose
    if isvalid(luo_pbcompiler) then destroy luo_pbcompiler
    else
    ls_return = "error"
    end if
    else
    ls_return = "error"
    end if
    if isvalid(lnv_pbcompiler) then destroy lnv_pbcompiler
    LibraryDelete(ls_libraryname)
    return ls_return
    end function
    三.f_parse
    $PBExportHeader$f_parse.srf
    $PBExportComments$分解字符串到数组
    global type f_parse from function_object
    end type
    forward prototypes
    global function long f_parse (readonly string as_text, readonly string as_sep, ref string as_list[])
    end prototypes
    global function long f_parse (readonly string as_text, readonly string as_sep, ref string as_list[]);/*******************************************************************
    函数名称:f_parse()
    参数: as_text string 来源字符串
    as_sep string 分隔字符
    as_list[] ref string 分析后形成的字符串数组
    返回值: long 分析后形成的数组元素个数
    功能描述:分析字符串到一个数组中
    创建人: 康剑民
    创建日期:2002-11-19
    版本号: V1.0
    *******************************************************************/
    long i,ll_pos
    string ls_null[],ls_text
    ls_text = as_text
    as_list = ls_null
    i=0
    ll_pos = posw(lower(ls_text),lower(as_sep))
    do while ll_pos > 0
    i ++
    as_list[i]=leftw(ls_text,ll_pos - 1)
    ls_text=midw(ls_text,ll_pos + lenw(as_sep),lenw(ls_text))
    ll_pos = posw(lower(ls_text),lower(as_sep))
    loop
    as_list[i + 1] = ls_text
    return upperbound(as_list[])
    end function
    四.f_replacetext
    $PBExportHeader$f_replacetext.srf
    $PBExportComments$替换字符串
    global type f_replacetext from function_object
    end type
    forward prototypes
    global function string f_replacetext (readonly string as_source, readonly string as_oldtag, readonly string as_newtag, readonly long al_seq)
    end prototypes
    global function string f_replacetext (readonly string as_source, readonly string as_oldtag, readonly string as_newtag, readonly long al_seq);/*******************************************************************
    函数名称:f_replacetext()
    参数: as_source string 源字符串
    as_oldtag string 待替换特征字符串
    as_newtag string 替换后特征字符串
    al_seq long 第几个特征替换字符串需替换,0表示全部
    返回值: string 替换后字符串
    功能描述:用一特征字符串替换指定字符串中的特征字符串,参数al_seq=0时表示全部替换
    创建人: 康剑民
    创建日期:2002-11-19
    版本号: V1.0
    *******************************************************************/
    long ll_start_pos=1,ll_len_old_tag,i = 0
    string ls_left,ls_return='',ls_source=''
    ls_source = as_source
    ll_len_old_tag = lenw(as_oldtag)
    ll_start_pos = posw(lower(ls_source),lower(as_oldtag),1)
    if al_seq = 0 then
    DO WHILE ll_start_pos > 0
    ls_left = leftw(ls_source,ll_start_pos - 1) + as_newtag
    ls_return = ls_return + ls_left
    ls_source = midw(ls_source,ll_start_pos + lenw(as_oldtag),lenw(ls_source))
    ll_start_pos = posw(lower(ls_source),lower(as_oldtag),1)
    LOOP
    elseif al_seq > 0 then
    DO WHILE ll_start_pos > 0
    i ++
    if al_seq = i then
    ls_left = leftw(ls_source,ll_start_pos - 1) + as_newtag
    ls_return = ls_return + ls_left
    ls_source = midw(ls_source,ll_start_pos + lenw(as_oldtag),lenw(ls_source))
    ll_start_pos = posw(lower(ls_source),lower(as_oldtag),1)
    end if
    loop
    end if
    ls_return = ls_return + ls_source
    return ls_return
    end function
    五.nvo_pbcompiler
    $PBExportHeader$nvo_pbcompiler.sru
    $PBExportComments$PB动态脚本解释器
    forward
    global type nvo_pbcompiler from nonvisualobject
    end type
    end forward
    global type nvo_pbcompiler from nonvisualobject
    end type
    global nvo_pbcompiler nvo_pbcompiler
    type prototypes
    //打开一个会话
    Function long SessionOpen () Library "PBORC90.DLL" Alias for "PBORCA_SessionOpen"
    //关闭一个会话
    Subroutine SessionClose ( long hORCASession ) Library "PBORC90.DLL" Alias for "PBORCA_SessionClose"
    //设置当前会话的库清单
    Function int SessionSetLibraryList ( long hORCASession, ref string pLibNames[], int iNumberOfLibs) Library "PBORC90.DLL" Alias for "PBORCA_SessionSetLibraryList"
    //设置当前会话对应的应用
    Function int SessionSetCurrentAppl ( long hORCASession, string lpszApplLibName, string lpszApplName ) Library "PBORC90.DLL" Alias for "PBORCA_SessionSetCurrentAppl"
    //导入并编译实体
    Function int CompileEntryImport ( long hORCASession, string lpszLibraryName, string lpszEntryName, long otEntryType, string lpszComments, string lpszEntrySyntax, long lEntrySyntaxBuffSize, long pCompErrorProc, long pUserData ) Library "PBORC90.DLL" Alias for "PBORCA_CompileEntryImport"
    //取临时目录
    Function long GetTempPath(long nBufferLength, ref string lpBuffer) Library "kernel32" Alias for "GetTempPathA"
    //获取一个已装载模板的完整路径名称
    FUNCTION ulong GetModuleFileName(ulong hModule,ref string lpFileName,ulong nSize) LIBRARY "kernel32.dll" ALIAS FOR "GetModuleFileNameA"
    end prototypes
    type variables
    end variables
    forward prototypes
    public function string of_gettemppath ()
    public function string of_getapppath ()
    public function integer of_createentry (string as_returntype, string as_pbscript, ref string as_libraryname, ref string as_entryname)
    end prototypes
    public function string of_gettemppath ();/*******************************************************************
    函数名称:of_gettemppath()
    参数: 无
    返回值: string 临时路径
    功能描述:取临时路径
    创建人: 康剑民
    创建日期:2006-12-26
    版本号: V1.0
    *******************************************************************/
    string ls_path
    ulong lu_size=256
    ls_path=space(256)
    GetTempPath(lu_size,ls_path)
    return trimw(ls_path)
    end function
    public function string of_getapppath ();/*******************************************************************
    函数名称:of_getapppath()
    参数: 无
    返回值: string 应用程序路径
    功能描述:取应用程序路径
    创建人: 康剑民
    创建日期:2002-11-22
    版本号: V1.0
    *******************************************************************/
    string ls_apppath
    ls_apppath=space(256)
    GetModuleFileName(Handle(GetApplication()),ls_apppath,256)
    ls_apppath=Reverse(ls_apppath)
    ls_apppath=Reverse(midw(ls_apppath,posw(ls_apppath,'/',1)))
    return ls_apppath
    end function
    public function integer of_createentry (string as_returntype, string as_pbscript, ref string as_libraryname, ref string as_entryname);/*******************************************************************
    函数名称:of_createentry()
    参数: as_returntype string 返回值类型
    as_pbscript string 动态代码
    as_libraryname ref string 创建的库文件名称
    as_entryname ref string 创建的实体名称
    返回值: long 是否成功(1表示成功,-1表示失败)
    功能描述:根据动态代码创建实体
    创建人: 康剑民
    创建日期:2007-02-12
    版本号: V1.0
    *******************************************************************/
    long ll_sid//会话编号
    long ll_index//对象序号
    string ls_librarylist[]//库文件列表
    string ls_librarylist_tmp[]//库文件列表(临时)
    string ls_temp_libraryname//临时库文件名称
    string ls_temp_path//临时目录
    string ls_syntax//实体语法
    string ls_app_libraryname//应用程序所在库文件名称
    integer li_result//结果
    string ls_entryname//对象名称
    classdefinition lcd_app//应用程序类定义对象
    string ls_librarylist_files//库文件
    integer i,j//临时变量
    //开发环境下直接退出
    if handle(GetApplication()) <= 0 then return -1
    //取库文件列表
    ls_librarylist_files = getlibrarylist ()
    //取应用对象所在pbl
    lcd_app = getapplication().classdefinition
    ls_app_libraryname = lcd_app.libraryname
    ls_temp_path = this.of_gettemppath( )//取临时目录
    //取待创建的临时库文件名称
    ll_index = 1
    ls_temp_libraryname = ls_temp_path + "temp"+string(ll_index) + ".pbl"
    do while fileexists(ls_temp_libraryname) or posw(","+ls_librarylist_files+",",","+ls_temp_libraryname+",") > 0
    ll_index ++
    ls_temp_libraryname = ls_temp_path + "temp"+string(ll_index) + ".pbl"
    loop
    //创建临时库文件
    LibraryCreate(ls_temp_libraryname,"临时库文件")
    f_parse(ls_librarylist_files,',',ls_librarylist)//分解字符串到数组
    //判断库文件是否存在并形成新列表
    j = 0
    for i = 1 to upperbound(ls_librarylist)
    if fileexists(ls_librarylist[i]) then
    j ++
    ls_librarylist_tmp[j] = ls_librarylist[i]
    end if
    next
    ls_librarylist = ls_librarylist_tmp
    ls_librarylist[upperbound(ls_librarylist)+1] = ls_temp_libraryname
    ll_sid = SessionOpen()//打开一个会话
    //设置当前会话的库清单
    li_result = SessionSetLibraryList (ll_sid, ls_librarylist, upperbound(ls_librarylist))
    if li_result = 0 then
    //设置当前会话对应的应用
    li_result = SessionSetCurrentAppl (ll_sid, ls_app_libraryname, getapplication().appname )
    if li_result = 0 then
    //取实体名称(保证不重复)
    ll_index = 1
    do while not isnull(FindClassDefinition("nvo_"+string(ll_index)))
    ll_index ++
    loop
    ls_entryname = "nvo_"+string(ll_index)
    //实体声明
    ls_syntax = "$PBExportHeader$"+ls_entryname+".sru"+"~r~n"&
    + "forward"+"~r~n"&
    + "global type "+ls_entryname+" from nonvisualobject"+"~r~n"&
    + "end type"+"~r~n"&
    + "end forward"+"~r~n"&
    + "~r~n"&
    + "global type "+ls_entryname+" from nonvisualobject"+"~r~n"&
    + "end type"+"~r~n"&
    + "global "+ls_entryname+" "+ls_entryname+""+"~r~n"&
    + "~r~n"&
    + "forward prototypes"+"~r~n"
    //区分函数还是过程
    if trimw(lower(as_returntype)) = 'none' or trimw(lower(as_returntype)) = '' then
    ls_syntax = ls_syntax + "public subroutine of_exec ()"+"~r~n"&
    + "end prototypes"+"~r~n"&
    + "~r~n"&
    + "public subroutine of_exec ();"+as_pbscript+"~r~n"&
    + "end subroutine"
    else
    ls_syntax = ls_syntax + "public function " + as_returntype + " of_exec ()"+"~r~n"&
    + "end prototypes"+"~r~n"&
    + "~r~n"&
    + "public function " + as_returntype + " of_exec ();"+as_pbscript+"~r~n"&
    + "end function"
    end if
    //实体语法尾部
    ls_syntax = ls_syntax + "~r~n" + "on " + ls_entryname + ".create"+"~r~n"&
    + "call super::create"+"~r~n"&
    + "TriggerEvent( this, ~"constructor~" )"+"~r~n"&
    + "end on"+"~r~n"&
    + "~r~n"&
    + "on " + ls_entryname + ".destroy"+"~r~n"&
    + "TriggerEvent( this, ~"destructor~" )"+"~r~n"&
    + "call super::destroy"+"~r~n"&
    + "end on"
    //导入并编译实体
    li_result = CompileEntryImport (ll_sid, ls_temp_libraryname, ls_entryname, 6 , "comment - new object", ls_syntax, len(ls_syntax), 0, 0 )
    end if
    end if
    SessionClose(ll_sid)//关闭一个会话
    as_libraryname = ls_temp_libraryname
    as_entryname=ls_entryname
    //加入新文件到库文件搜索列表
    AddToLibraryList(ls_temp_libraryname)
    if li_result = 0 then
    return 1
    else
    return -1
    end if
    end function
    on nvo_pbcompiler.create
    call super::create
    TriggerEvent( this, "constructor" )
    end on
    on nvo_pbcompiler.destroy
    TriggerEvent( this, "destructor" )
    call super::destroy
    end on
    六.w_pbcompiler_test
    $PBExportHeader$w_pbcompiler_test.srw
    $PBExportComments$PB动态脚本解释器测试窗口
    forward
    global type w_pbcompiler_test from window
    end type
    type st_returnvalue from statictext within w_pbcompiler_test
    end type
    type st_returntype from statictext within w_pbcompiler_test
    end type
    type st_script from statictext within w_pbcompiler_test
    end type
    type sle_returnvalue from singlelineedit within w_pbcompiler_test
    end type
    type cb_exit from commandbutton within w_pbcompiler_test
    end type
    type sle_returntype from singlelineedit within w_pbcompiler_test
    end type
    type mle_script from multilineedit within w_pbcompiler_test
    end type
    type cb_ok from commandbutton within w_pbcompiler_test
    end type
    end forward
    global type w_pbcompiler_test from window
    integer width = 1979
    integer height = 1100
    boolean titlebar = true
    string title = "PB脚本解释器(测试)"
    boolean controlmenu = true
    boolean minbox = true
    boolean maxbox = true
    boolean resizable = true
    long backcolor = 67108864
    string icon = "AppIcon!"
    boolean center = true
    st_returnvalue st_returnvalue
    st_returntype st_returntype
    st_script st_script
    sle_returnvalue sle_returnvalue
    cb_exit cb_exit
    sle_returntype sle_returntype
    mle_script mle_script
    cb_ok cb_ok
    end type
    global w_pbcompiler_test w_pbcompiler_test
    type prototypes
    end prototypes
    type variables
    end variables
    on w_pbcompiler_test.create
    this.st_returnvalue=create st_returnvalue
    this.st_returntype=create st_returntype
    this.st_script=create st_script
    this.sle_returnvalue=create sle_returnvalue
    this.cb_exit=create cb_exit
    this.sle_returntype=create sle_returntype
    this.mle_script=create mle_script
    this.cb_ok=create cb_ok
    this.Control[]={this.st_returnvalue,&
    this.st_returntype,&
    this.st_script,&
    this.sle_returnvalue,&
    this.cb_exit,&
    this.sle_returntype,&
    this.mle_script,&
    this.cb_ok}
    end on
    on w_pbcompiler_test.destroy
    destroy(this.st_returnvalue)
    destroy(this.st_returntype)
    destroy(this.st_script)
    destroy(this.sle_returnvalue)
    destroy(this.cb_exit)
    destroy(this.sle_returntype)
    destroy(this.mle_script)
    destroy(this.cb_ok)
    end on
    type st_returnvalue from statictext within w_pbcompiler_test
    integer x = 9
    integer y = 608
    integer width = 297
    integer height = 60
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    long backcolor = 67108864
    string text = "返回值:"
    boolean focusrectangle = false
    end type
    type st_returntype from statictext within w_pbcompiler_test
    integer x = 9
    integer y = 476
    integer width = 297
    integer height = 60
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    long backcolor = 67108864
    string text = "返回值类型:"
    boolean focusrectangle = false
    end type
    type st_script from statictext within w_pbcompiler_test
    integer x = 9
    integer y = 12
    integer width = 206
    integer height = 60
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    long backcolor = 67108864
    string text = "PB脚本:"
    boolean focusrectangle = false
    end type
    type sle_returnvalue from singlelineedit within w_pbcompiler_test
    integer x = 334
    integer y = 608
    integer width = 1582
    integer height = 104
    integer taborder = 30
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    borderstyle borderstyle = stylelowered!
    end type
    type cb_exit from commandbutton within w_pbcompiler_test
    integer x = 1664
    integer y = 856
    integer width = 242
    integer height = 104
    integer taborder = 50
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    string text = "退出"
    end type
    event clicked;close(parent)
    end event
    type sle_returntype from singlelineedit within w_pbcompiler_test
    integer x = 334
    integer y = 476
    integer width = 1582
    integer height = 104
    integer taborder = 20
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    borderstyle borderstyle = stylelowered!
    end type
    type mle_script from multilineedit within w_pbcompiler_test
    integer x = 334
    integer y = 12
    integer width = 1582
    integer height = 432
    integer taborder = 10
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    long textcolor = 33554432
    boolean vscrollbar = true
    boolean autovscroll = true
    borderstyle borderstyle = stylelowered!
    end type
    type cb_ok from commandbutton within w_pbcompiler_test
    integer x = 1417
    integer y = 856
    integer width = 242
    integer height = 104
    integer taborder = 40
    integer textsize = -9
    integer weight = 400
    fontcharset fontcharset = ansi!
    fontpitch fontpitch = variable!
    fontfamily fontfamily = swiss!
    string facename = "Arial"
    string text = "执行"
    end type
    event clicked;sle_returnvalue.text = f_execpbscript(sle_returntype.text,mle_script.text)
    end event

  • 相关阅读:
    win7下virtualbox遇到的问题
    2.5年, 从0到阿里
    TCP/IP入门(4) --应用层
    TCP/IP入门(3) --传输层
    TCP/IP入门(2) --网络层
    TCP/IP入门(1) --链路层
    Socket编程实践(13) --UNIX域协议
    Socket编程实践(12) --UDP编程基础
    Socket编程实践(10) --select的限制与poll的使用
    Socket编程实践(9) --套接字IO超时设置方法
  • 原文地址:https://www.cnblogs.com/wallis0922/p/3513188.html
Copyright © 2011-2022 走看看