6.1 Command Line

The command line refers to using commands in the form of strings in DOS-like environment to execute programs. All operating systems support the command lines, like the Linux console and the Windows command line window.

The esprocx.exe file, which is located in the esProc\bin path in esProc’s installation directory, is needed when using the command line to execute an esProc cellset file.

Cellset files without return results

Use the esprocx command to execute a cellset file at command line. Take the following cellset file, D:\files\output1.dfx, as an example:

 

A

B

1

=create(ID,Amount)

 

2

for 100

>A1.insert(0,#A2,rand(100*100))

3

=file("D:\\files\\Data1.txt")

>A3.export@t(A1)

Cellset files without return results are usually those that access data in files or databases. In the above cellset, for example, some simulation data is created and stored in the text file Data1.txt. When using an esprocx command, enter the to-be-executed dfx file after it; during execution, prompts of start and end will be displayed on the screen, as shown below:

After the execution, the randomly generated data will be written into Data1.txt, as shown below:

If the path in which the esprocx file is located is included into the operating system’s path list, run the file directly instead of running it in the esProc\bin path of the installation directory. But the to-be-called dfx file must be entered in its full path, or should be located in the current path. For example:

If the to-be-executed cellset file uses parameters, enter their values, separated by spaces, after the dfx file when executing the esprocx command. Take the following cellset file D:\files\output2.dfx as an example:

 

A

B

1

=file("D:\\files\\Data1.txt")

=A1.import@t()

2

for IDs

>B1.modify(A2,Value:Amount)

3

>A1.export@t(B1)

 

The file uses two parameters: IDs and Value, as shown below:

The cellset is to import the Data1.txt file just created, modify some of the records with specified sequence numbers to make their Amount fields eqivalent to the specified Value, and store these records in the file again. The prompts displayed on the screen during execution are as follows:

Two parameters, one is a sequence [2,3,5,7,11], and the other is an integer 99999, are input while the cellset file, output2.dfx, is called. Similar to a cross-cellset call, the input parameters will be assigned to the cellset parameters according to their order instead of their names during the command line call. In this case [2,3,5,7,11] is assigned to the first parameter IDs and 99999 is assigned to the second parameter Value. After the command line is executed, data in Data1.txt will have been modified:

Cellset files with return results

When using the esprocx command directly at the command line, by default the result won’t be displayed on the screen. To display the return result of the dfx file, use -R option in execution. Similar to the cellset file called by the call function, the dfx file must return the result using return statement. Take the following cellset file, D:\files\calculate1.dfx, as an example:

 

A

B

1

=days(Day)

=string(Day,"EEE")

2

return A1

return B1

This cellset will return the total number of days of the month in which the specified date occurs and compute what day the specified date is. It uses Day as one of its parameters:

Let’s first look at the execution with -R option:

Here no parameter has been set for the execution and a default one, 01/01/2000, is used for the computation. You can see that A2 and B2 respectively return a result using return statement. The results will be listed respectively after computation.

To set a parameter, it should be the date type. As a parameter of date type or time type has its own format, you need to set the format in the configuration file raqsoftConfig.xml located in esProc\config path in esProc’s installation directory:

<Esproc>

<dateFormat> yyyy-MM-dd</dateFormat>

<timeFormat>HH:mm:ss</timeFormat>

<dateTimeFormat> yyyy-MM-dd HH:mm:ss</dateTimeFormat>

</Esproc>

The execution is what the following shows if a parameter has been set for the call:

This time you get the total number of days of the month in which February 22, 2012 occurs and the day of the week for this date.

Different from the previous cellset file, the following D:\files\calculate2.dfx returns results as a sequence:

 

A

B

1

=days(Day)

=string(Day,"EEE")

2

return [A1,B1]

 

The execution is as follows:

Members of the resulting sequence are listed respectively, each having a line.

Here comes the last sample of the cellset file - D:\files\calculate3.dfx:

 

A

B

1

$(demo) select * from CITIES

$select * from STATES

2

=A1.switch(STATEID,B1:STATEID)

=A2.new(CID,NAME:City,STATEID.NAME:State)

3

=B2.select(left(City,1)==Letter)

 

4

return A3

 

The cellset file uses a parameter - Letter:

This cellset uses the database data. Here the database connection needs to be configured in the raqsoftConfig.xml file in the esProc\config path in the esProc installation directory:

<DBList encryptLevel="0">

<DB name="demo">

<property name="url" value="jdbc:hsqldb:hsql://127.0.0.1/demo"/>

<property name="driver" value="org.hsqldb.jdbcDriver"/>

<property name="type" value="13"/>

<property name="user" value="sa"/>

<property name="password" value=""/>

<property name="batchSize" value="1000"/>

<property name="autoConnect" value="true"/>

<property name="useSchema" value="false"/>

<property name="addTilde" value="false"/>

</DB>

</DBList >

Please refer to related documents for detailed configuration method.

When the program is executed, the result is as follows:

To set a parameter of string type, it’s not necessary to surround it with double quotation marks, just enter it directly. Cities whose names start with letter B are listed in the above result. For a result of table sequence type or record sequence type, each record occupies a line and fields are separated from each other by tabs.

The above-mentioned configuration file, raqsoftConfig.xml, is also shared by the Integrated Development Environment (IDE), so information, like date format and datasource configuration, can be edited on the IDE interface. Click Tool>Option on the menu bar and configure the information on the Option window’s Environment page:

Click Tool>Datasource connection in Datasource manager to configure database connection parameter and other information. For details, refer to Database Configuration.

Executing cellset script and simple SQL

We can add -c option after an esprocx command to execute an input cellset script. In the cellset script, columns are separated by the Tab and lines are separated by the carriage return. Press Ctrl+C to finish the input and start execution. For example:

After starting the execution of esprocx –c, the following script is input:

[]  >10.(A1=A1|#)

>output(A1)

According to the cellset script, ten numbers are added to A1’s empty sequence and line 2 exports the sequence to the console. After pressing Ctrl+C, we get the output result in the console.

To view the result of executing the cellset script, the common way is to add -r option, as shown below:

By executing esprocx –r –c, we get the result of computing the cellset script. If there isn’t a return statement in the cellset script, the command will return the value of executing the last cell.

We can also execute a simple SQL statement at the command line to query a data file on the main directory. For example:

Usually -r option is used when executing a simple SQL statement. For more information about executing simple SQL at command line, see Simple SQL. To query database data, certain settings need to be first completed in raqsoftConfig.xml file.