Home | About SQeeL | Document | DownLoad | Mail Japanese
Home > Document > SQeeL Reference

Input and output function

  • Built-in function
  • close()
    Description
    Closes file specified by a file ID argument
    Syntax
    ret = close(filehandle)
    Parameters
    filehandle:File number
    Default: all file numbers that are currently open
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    5File number error
    Example
    make_newfile()
    exit
    
    function make_newfile()
    
    	local fno
    
    	fno = open('foge.txt', new)
    		print('hello world', fno)
    	close(fno)
    
    endfunction
    
    Topへ
    flush()
    Description
    Flush the disk cache without closing the file.
    A specified file must be opened in read mode
    Normally, this function is not used
    Syntax
    ret = flush(filehandle)
    Parameters
    filehandle:File number
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    5File number error
    Example
    //[result example]
    //
    // 1 : hello world
    // 2 : foge
    // 3 : foo
    // 4 : goo
    // 5 : boo
    //
    
    get_fileline_to_flush()
    exit
    
    function get_fileline_to_flush()
    
    	local i
    	local lineString = ''
    	local fno
    
    	fno = open('foo.txt', read)
    
    	loop i=1; ; i++
    		lineString = readline(fno)
    		if ERROR != 0
    			break
    		endif
    
    		print('${i} : ${lineString}', STDOUT)
    		flush(STDOUT)
    
    	endloop
    
    	close(fno)
    
    endfunction
    
    
    Topへ
    open()
    Description
    Opens file
    The returned value of file ID is used in the following functions of filehandles
    If file is open in write mode, the output file will be the opened file as default.
    Syntax
    ret = open(filename,mode)
    Parameters
    filename:File name to open
    mode:Mode to open a file
    Default: NEW
    You can specify NEW, APPEND, and READ which are defined as system variable.
    Return Value
    positive integral number:File number
    0:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    4OPEN error
    7SEEK error
    See Also
    Example
    make_newfile()
    exit
    
    function make_newfile()
    
    	local fno
    
    	fno = open('foge.txt', new)
    		print('hello world', fno)
    	close(fno)
    
    endfunction
    
    Topへ
    output()
    Description
    Sets and changes the default of output file
    A specified file must be open in write mode
    Syntax
    ret = output(filehandle)
    Parameters
    filehandle:File number
    Default: system variable STDOUT
    Return Value
    1:Success
    System Return Value
    ERROR
    0Success
    Example
    //[result example]
    //
    // [odd.txt]      [even.txt]
    // 1              2
    // 3              4
    // 5              6
    // 7              8
    // 9              10
    //
    
    make_newfile2()
    exit
    
    function make_newfile2()
    
    	local i
    	local fno
    	local fid
    
    	fno = open('odd.txt', new)
    	fid = open('even.txt', new)
    
    	loop i=1; i<=10; i++
    		if i % 2 == 0 /* even number */
    			output(fid)
    		else
    			output(fno)
    		endif
    		print('${i}')
    	endloop
    
    	close(fno)
    	close(fid)
    
    endfunction
    
    
    
    Topへ
    print()
    Description
    Outputs specified character string to the file
    The output file must be opened in write mode
    Syntax
    ret = print(string,filehandle)
    Parameters
    string:character string to be printed
    filehandle:File number
    Default: system variable STDOUT
    You can specify STDOUT, STDERR, and STDLOG which are defined as system variable.
    Return Value
    NULL:Fail or printed character string
    string:Printed character string
    System Return Value
    ERROR
    0Success
    1Argument error
    2Output error
    5File number error
    See Also
    Example
    //[result example]
    //
    // Hello
    // World !
    // ********************
    // HelloWorld !
    //
    
    
    make_newfile3()
    exit
    
    function make_newfile3()
    
    	local fno
    
    	fno = open('boo.txt', new)
    		print('Hello', fno)
    		print('World !', fno)
    		print('********************', fno)
    		printstring('Hello', fno)
    		printstring('World !', fno)
    	close(fno)
    
    endfunction
    
    
    
    Topへ
    printstring()
    Description
    Outputs specified character string to the file
    Equivalent to print, except for no line feed
    The output file must be opened in write mode
    Syntax
    ret = printstring(string,filehandle)
    Parameters
    string:Character string to be printed
    filehandle:File number
    Default: system variable STDOUT
    You can specify STDOUT, STDERR, and STDLOG which are defined as system variable.
    Return Value
    NULL:Fail or printed character string
    string:Printed character string
    System Return Value
    ERROR
    0Success
    1Argument error
    2Output error
    5File number error
    See Also
    Example
    //[result example]
    //
    // Hello
    // World !
    // ********************
    // HelloWorld !
    //
    
    
    make_newfile3()
    exit
    
    function make_newfile3()
    
    	local fno
    
    	fno = open('boo.txt', new)
    		print('Hello', fno)
    		print('World !', fno)
    		print('********************', fno)
    		printstring('Hello', fno)
    		printstring('World !', fno)
    	close(fno)
    
    endfunction
    
    
    
    Topへ
    readline()
    Description
    Reads one row per line and returns it as character string.
    A specified file must be opened in read mode
    Syntax
    ret = readline(filehandle)
    Parameters
    filehandle:File number
    Return Value
    NULL:Fail or printed character string
    string:Printed character string
    System Return Value
    ERROR
    0Success
    1Argument error
    5File number error
    15No character strings to read
    Example
    //[result example]
    //
    // 1 : hello world
    // 2 : foge
    // 3 : foo
    // 4 : goo
    // 5 : boo
    
    get_fileline()
    exit
    
    function get_fileline()
    
    	local i
    	local lineString = ''
    	local fno
    
    	fno = open('foo.txt', read)
    
    	loop i=1; ; i++
    		lineString = readline(fno)
    		if ERROR != 0
    			break
    		endif
    
    		print('${i} : ${lineString}', STDOUT)
    
    	endloop
    
    	close(fno)
    
    endfunction
    
    
    Topへ

    © Insight Technology, Inc. 1996-2003 All Rights Reserved.