function replace(fstr as string,rstr as string,tstr as string) as string
//r5適用
'''''''''''''''''''''''
'fstr 要處理的字串
'rstr 要替換的字串
'tstr 字串替換目標
''''''''''''''''''''''''
while instr(fstr,rstr)>0
strtemp=strleft(fstr,rstr)+tstr+strright(fstr,rstr)
fstr=strtemp
wend
replace=fstr
end function
function split(strsoucer as string,sp as string) as variant
//r5適用
dim y() as string
dim strtemp as string,i as integer
i=0while instr(strsoucer,sp)>0 and strsoucer<>""
redim preserve y(i)
strtemp=strleft(strsoucer,sp)
y(i)=strtemp
strsoucer=strright(strsoucer,sp)
i=i+1
wend
redim preserve y(i)
y(i)=strsoucer
split=y
end function
sub getv()
'lotus script 檔案操作
dim filenum as integer
dim filename as string
filenum% = freefile()
filename$ = "d:/nluserenpass.ini"
open filename$ for random as filenum%
dim rec as string
seek filenum%, 1
do while not eof(filenum%)
get #filenum%, , rec
print rec
loop
close filenum%
end sub
function getinivalue(section as string,key as string,filepath as string) as string
''''''''''''''''''''''''''''
'ini 檔案操作,引用此函式注意**許可權最低為2
'獲取ini檔案中某一項值
''''''''''''''''''''''''''''
on error goto errorh
dim session as new notessession
dim stream as notesstream
set stream=session.createstream
dim flag_isin_sec as boolean,flag_geted as boolean
dim rtstr as string
flag_isin_sec=false
flag_geted=false
section="["+section+"]"
if not stream.open(filepath, "gb2312") then
messagebox filepath,, "open failed"
exit function
end if
key=key+"="
while not stream.iseos and not flag_geted
buffer$ = trim(stream.readtext(stmread_line,eol_platform))
buffer$=replace(replace(trim(buffer$),chr(13),""),chr(10),"")
if flag_isin_sec then
'首先查詢 section 直到下個section出現
if left(buffer$,1)="[" and right(buffer$,1)="]" then
flag_isin_sec=false
end if
end if
if buffer$=section then
flag_isin_sec=true
end if
if flag_isin_sec then
if instr(buffer$,key)>0 then
rtstr=strright(buffer$,"=")
flag_geted=true
end if
end if
wend
stream.close
getinivalue=replace(replace(trim(rtstr),chr(13),""),chr(10),"")
exit function
errorh:
dim serror as new notessession
dim dberror as notesdatabase
dim agerror as notesagent
set agerror=serror.currentagent
set dberror=serror.currentdatabase
msgbox dberror.title+"("+dberror.filepath+")::"+agerror.name+_
"->lsini->getinivalue->error="+error+":erl="+cstr(erl)
exit function
end function
一些NDIS函式
最近在做虛擬網絡卡驅動,整理了一些函式 npaged lookaside list 是乙個不透明的鍊錶,可以從分配確定長度的非分頁記憶體,系統會建立或銷毀鍊錶中的記憶體.對於確定長度的記憶體比直接分配記憶體快。必須呼叫 ndisinitializenpagedlookasidelist 初始化乙個鍊...
APUE 一些函式
times函式 測量程序時間的函式 8.16 getrusage 程序使用資源 getconf 也是一些資源 和上面getrusage有啥不同 df report file system disk space usage setbuf函式 setbuf函式具有開啟和關閉緩衝機制。system函式 定...
一些oracle函式
使用case表示式直接在select語句中執行條件邏輯 select ename,sal,case when sal 2000 then underpaid when sal 4000 then overpaid else ok end as status from emp coalesce函式用實...