- 积分
- 0
- 注册时间
- 2014-2-26
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2016-3-14 03:47:50
|
显示全部楼层
来自 北京
- OPEN、CLOSE 用法
- ;close 当前文件关闭,返回值为0表示成功关闭
- open(filename,wr,mode) '先打开文件,然后 可以读,可以往里写内容
- ;===filename可以是带双引号的字符串,也可以是变量名。
- ;===wr必须是个整数:0-只读打开,文件要求存在;1-文件为写入打开,已经存在的文件将被覆盖 (overwritten)。2-文件为写入打开,存在的文件被改写(appended to)
- ;===mode必须为一个整数值,0-读写fish变量,只有整型,浮点型和字符串的数据类型被传输,不传递变量名。1-读写ASCII数据。可读入一行数据,行之间用 CR/LF分开。每行最大80字符。
- ;===2-设定为binary读模式,任何文件都以binary的读取模式打开.
- ;===返回值: 0表示文件打开成功;1-表示文件名不是字符串;2-文件名是一个空字符串;3-wr或mode不是整型;4-mode参数错误(不是0或1);5-wr参数 错误(不是0或1);6-不能打开所要读取的文件,比如文件不存在;7-文件已经打开;8-不是fish模式的文件
- ;read(ar,n) ---放入数组。读取n个记录放入数组ar,每个记录要求是一行ASCII数据,或者是一个FISH变量。数组至少有n个元素大小。
- ;====返回值0表示无误;-1:表示读取错误,比如到了文件的末尾;n-表示读入n行后,恰好到了文件的末尾。
- ;****************************************
- READ(ar, n) 将n个记录写到数组ar
- read(ar, n) reads n records into the array ar. The array ar must be an array of at least n elements. The returned value is:
- 0 requested number of lines were input without error
- -1 error on read (except end-of-file)
- n positive value indicates that end-of-file was encountered after
- reading n lines
- write(ar, n) 将数组ar的前n个记录 写到文件,详细:
- write(ar, n) writes n records from the first n elements of the array ar. The array ar must be an array of at least n elements. The returned value is:
- 0 requested number of lines were output without error
- -1 error on write
- n positive value (in ASCII mode) indicates that the nth element was not a string
- parse(s, i) This function scans the string s and decodes the ith item
- pre_parse(s, i) This function scans the string s and returns an integer value according to the type of the ith item, as follows.
- 0 missing item
- 1 integer
- 2 float
- 3 string missing (unable to interpret as int or float)
- type(e) 数据类型函数,1=整型,2=浮点,3=字符串,4=指针,5=数组
复制代码 |
|