首先选择程序类以创建filename.tns文件
在文件中定义函数库访问为LibPub ) )。
//int,string,stringdefinelibpubpinmode pinnum,mode,pin )=prgmlocalstrstr :=’ connect ‘ mode ‘ string pinum )=prgmsend ‘ begin ‘ delvariostr.str0getstr iostr.str0disp iostr.str0endp RGM//int, intdefinelibpubdigitalwrite data )=PRG mstr :=’ set digital.out ‘ string pin ) ‘ TO ‘dataSend strEndPrgm //int,int data )=PRG mstr :=’ set analog.out ‘ string pin ) ‘ to’string ) data ) Send strEndPrgm //int, intdefinelibpubdiging buffer =PRG mstr :=’ readdigital.in ‘ string pin ) getx buffer 3360=xdelvarstrendprgm//iing intdefinelibpubananager buffer )=PRG mstr :=’ read analog.in ‘ string pin ) sendstrgetxbuffer 3360=xdelvarstrendprgm
在其他. tns文件中调用的语法为filename\funcname )