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

System call

  • Built-in function
  • getenv()
    Description
    Returns OS environmental variable specified by argument
    Syntax
    ret = getenv(string)
    Parameters
    string:Environment variable name
    Return Value
    NULL:Error or environment variable
    string:Environment variable
    System Return Value
    ERROR
    0Success
    1Argument error
    8GETENV error
    Example
    //[result example]
    //
    //OS=Windows_NT
    //
    
    run()
    exit
    
    function run()
    
    	print('OS=${getenv("OS")}')
    
    endfunction
    
    
    Topへ
    getopt()
    Description
    (Parases and) Returns the argument specified at command line
    If the number of arguments specified, the value of argument will be stored sequentially as array variable
    When there is no argument, a prompt will appear. The input character will be retunred.
    Syntax
    ret = getopt(string,{ … })
    Parameters
    string:Prompt for asking the user to input
    Default: 'ARG[n]=' (n represents the number of times the user inputs)
    { … }:multiple strings can be specified.
    Return Value
    NULL:Error or character string passed by the user
    string:Character string passed by the user
    System Return Value
    ERROR
    0Success
    2Output error
    3Input error
    Example
    //[result example]
    //
    // input word[1]: h
    // input word[2]: e
    // input word[3]: l
    // input word[4]: l
    // input word[5]: o
    // input word[6]:
    // input word[7]: w
    // input word[8]: o
    // input word[9]: r
    // input word[10]: l
    // input word[11]: d
    // input word[12]: exit
    // input word is hello world
    //
    
    exit input_stdin()
    
    function input_stdin()
    
    	local i
    	local input = ''
    	local word  = ''
    
    	loop i=1; ; i++
    		input = getopt('input word[${i}]: ')
    		if input eq 'q'
    			print( "input word is ${word}" )
    			break
    		else
    			word  = word & input
    		endif
    	endloop
    
    endfunction
    
    
    Topへ
    setenv()
    Description
    Sets the environmental variable specified by argument
    Syntax
    ret = setenv(string1,string2)
    Parameters
    string1:Environment variable name
    string2:setting value
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //ABC=sample
    //
    
    run()
    exit
    
    function run()
    
    	setenv('ABC', 'sample')
    	print('ABC=${getenv("ABC")}')
    
    endfunction
    
    
    Topへ
    sleep()
    Description
    Suspend the execution of program for specified period (second)
    Syntax
    ret = sleep(sec)
    Parameters
    sec:Sleep time (seconds)
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //input suspend time(sec): 30
    //now suspending...
    //30 seconds suspended.
    //
    
    sleeptime()
    exit
    
    function sleeptime()
    
    	local input_time = 10
    
    	input_time = getopt('input susptend time(sec): ')
    	print('now suspending...')
    	sleep(input_time)
    	print('${input_time} seconds susptended.')
    
    endfunction
    
    Topへ
    system()
    Description
    Executes OS command
    Syntax
    ret = system(string)
    Parameters
    string:command line
    Return Value
    0:Error or exit code of command
    1 or more:exit code
    -1:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    6Process startup fails
    Example
    run()
    exit(0)
    
    function run()
    
    	local s_file
    	local n_rc = 0
    
    	s_file = getopt('delete file: ')
    
    	print("\n*** system(\"cmd /c del /q " & s_file & "\") ***\n", stdout)
    
    	// system
    	n_rc = system('cmd /c del /q ' & s_file)
    
    	if n_rc == 0
    		print("completed.", stdout)
    	endif
    
    	print("--------------------------------", stdout)
    
    endfunction
    
    Topへ
    systemtime()
    Description
    Measures the execution time of process(program)
    Returns the time in acutual number for each argument (second)
    Syntax
    ret = systemtime(sys,user,rtime)
    Parameters
    sys:CPU time executed in privilege mode
    user:CPU time executed in user mode
    rtime:Time required for execution
    Return Value
    1:Success
    System Return Value
    ERROR
    0Success
    Example
    //[result example]
    //
    // ....0
    // ....1
    // ....2
    // ....3
    // ....4
    // ....5
    // ....6
    // ....7
    // ....8
    // ....9
    // sys=0.000000 : user=0.000000 : rtime=10.024000
    //
    
    run()
    exit
    
    function run()
    	local t_sys, t_user, t_rtime, j
    	
    	loop j=0; j<10; j++
    		print('....${j}')
    		sleep(1)
    	endloop
    	
    	systemtime(t_sys, t_user, t_rtime)
    	print('sys=${t_sys} : user=${t_user} : rtime=${t_rtime}')
    
    endfunction
    
    

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