MasteringVFP/2/6/1

出自VFP Wiki

在2006年5月27日 (六) 00:14由Elleryq (對話 | 貢獻)所做的修訂版本
(差異) ←上一修訂 | 最新修訂 (差異) | 下一修訂→ (差異)
跳轉到: 導航, 搜尋

Procedure

程序,我們可以將常用的指令集合到一起~這樣就不必再剪貼那麼多程式碼了~

例如:

use customers
go top
locate for cust_id=="A"
if found()
  && do something
endif
use in customers

use customers
go top
locate for cust_id=="B"
if found()
  && do something
endif
use in customers

我們就可以化簡為:

do findCustomer with "A"
do findCustomer with "B"

procedure findCustomer
  lparameters lc_id
  use customers
  go top
  locate for cust_id==lc_id
  if found()
    && do something
  endif
  use in customers
endproc

這樣不是簡單許多嗎?? 一般來說, Procedure 是不會傳回值的,但 VFP 的 Procedure 比較特別,它可以傳回值也可以不傳回值.