PB程式碼動態解析執行器

pb8發表於2009-10-11

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

相關文章