Try OpenEdge Now
skip to main content
Programming Interfaces
Command and Utility Reference : QUOTER utility
 

QUOTER utility

The QUOTER utility formats character data in a file to the standard format so it can be used by an ABL (Advanced Business Language) procedure. By default, QUOTER does the following:
*Takes the name of a file as an argument
*Reads input from that file
*Places quotes (") at the beginning and end of each line in the file
*Replaces any already existing quotes (") in the data with two quotes (" ")
You can use the QUOTER utility directly from the operating system using the operating system statement, as appropriate, to reformat data from a file that is not in the standard ABL input format:
Operating system
Syntax
UNIX
Windows
quoter input-file-name
  [ > output-file-name
   | -d character
   | -c startcol-stopcol
  ]...
input-file-name
Specifies the file you are using.
> output-file-name
Specifies the file where you want to send the output.
-d character
Identifies a field delimiter. You can specify any punctuation character.
-c startcol-stopcol
Specifies the ranges of column numbers to be read as fields. Do not use any spaces in the range list.
Suppose your data file looks like i-datf12.d.
i-datf12.d
90
Wind Chill Hockey
BBB
91
Low Key Checkers
DKP
92
Bing's Ping Pong
SLS
You use QUOTER to put this file into standard format. Use commands shown in the following table to run QUOTER from the Procedure Editor.
Table 84. QUOTER examples
Operating system
Using QUOTER—Examples
Windows
DOS quoter i-dat12.d >i-dat12.q
UNIX
UNIX quoter i-datf12.d >i-datf12.q
In the following figure, i-datfl2.d is the name of the data file you supply to QUOTER while i-datfl2.q is the name of the file in which you want to store QUOTER's output.
Figure 69. How QUOTER prepares a file
The i-datfl2.q file contains the QUOTER output.
i-datf12.q
"90"
"Wind Chill Hockey"
"BBB"
"91"
"Low Key Checkers"
"DKP"
"92"
"Bing's Ping Pong"
"SLS"
Now this file is in the appropriate format to be used as input to an ABL procedure.
What if each of the field values in your data file is not on a separate line (unlike i-datfl2.d) and without quotes (unlike i-datf1.d)? That is, your data file looks like i-datfl3.d.
i-datf13.d
90 Wind Chill Hockey  BBB
91 Low Key Checkers   DKP
92 Bing's Ping Pong   SLS
Suppose you wanted to use this file as the input source to create customer records for customers 90, 91, and 92. You need to make each line of the file into a character string and then assign a substring of this value to each field. The procedure i-chgin3.p does that.
i-chgin3.p
       DEFINE VARIABLE data AS CHARACTER NO-UNDO FORMAT "x(78)".

/*1*/  OS-COMMAND SILENT quoter i-datfl3.d > i-datfl3.q.
/*2*/
  INPUT FROM i-datfl3.q NO-ECHO.

       REPEAT:
/*3*/    CREATE Customer.
/*4*/    SET data WITH NO-BOX NO-LABELS NO-ATTR-SPACE WIDTH-CHARS 80.
         ASSIGN
           Customer.CustNum  = INTEGER(SUBSTRING(data,1,2))
           Customer.Name     = SUBSTRING(data,4,17)
/*5*/      Customer.SalesRep = SUBSTRING(data,22,3).
       END.

/*6*/  INPUT CLOSE.
The numbers to the left of the procedure correspond to the following step-by-step descriptions:
1. The QUOTER utility takes the data from the i-datfl3.d file and produces data that looks like the i-datf13.q example.
i-datf13.q
"90 Wind Chill Hockey BBB"
"91 Low Key Checkers DKP"
"92 Bing's Ping Pong SLS"
2. The INPUT FROM statement redirects the input stream to get input from the i-datfl3.q file.
3. The CREATE statement creates an empty customer record.
4. The SET statement uses the first quoted line in the i-datfl3.q file as input and puts that line in the data variable. Once that line of data is in the line variable, the next statements break it up into pieces that get stored in individual customer fields.
5. The SUBSTRING functions take the appropriate pieces of the data in the line variable and store the data in the cust–num, name, and sales–rep fields, as shown in the following figure.
Figure 70. Extracting QUOTER input with SUBSTRING
Because ABL assumes that all the data in the i-datfl3.q file is character data, you must use the INTEGER function to convert the cust–num data to an integer value.
6. The INPUT CLOSE statement closes the input stream coming from the i-datfl3.q file and redirects the input stream to the terminal.
Note: With this method, all trailing blanks are stored in the database. To avoid this problem, use the –c or –d option of QUOTER.
You can use QUOTER to prepare files formatted in other ways as well. For example, suppose the field values in your data file are separated by a specific character, such as a comma (,), as in i-datfl4.d.
i-datf14.d
90,Wind Chill Hockey,BBB
91,Low Key Checkers,DKP
92,Bing's Ping Pong,SLS
You can use a special option, -d, (on UNIX) to tell QUOTER what character separates fields. The procedure i-chgin4.p reads the comma-separated data from i-datfl4.d.
i-chgin4.p
OS-COMMAND SILENT quoter -d , i-datfl4.d >i-datfl4.q.

INPUT FROM i-datfl4.q NO-ECHO.
REPEAT:
  CREATE Customer.
  SET Customer.CustNum Customer.Name Customer.SalesRep.
END.
INPUT CLOSE.
Here, the -d option or the DELIMITER qualifier tells QUOTER that a comma (,) is the delimiter between each field in the data file. The output of QUOTER is shown in i-datfl4.q.
i-datf14.q
"90" "Wind Chill Hockey" "BBB"
"91" "Low Key Checkers"  "DKP"
"92" "Bing's Ping Pong"  "SLS"
This data file is in the standard blank-delimited ABL format. If your data file does not use a special field delimiter that you can specify with the –d QUOTER option or the /DELIMITER qualifier, but does have each data item in a fixed column position, you can use another special option, –c, on Windows and UNIX.
You use the –c option or /COLUMNS to identify the columns in which fields begin and end. For example, suppose your file looks like i-datfl5.d.
i-datf15.d
90 Wind Chill Hockey BBB
91 Low Key Checkers  DKP
92 Bing's Ping Pong  SLS
The procedure i-chgin5.p uses this data file to create customer records.
i-chgin5.p
OS-COMMAND SILENT quoter -c 1-2,4-20,22-24 i-datfl5.d >i-datfl5.q.

INPUT FROM i-datfl5.q NO-ECHO.
REPEAT:
  CREATE Customer.
  SET Customer.CustNum Customer.Name Customer.SalesRep.
END.
INPUT CLOSE.
Because you used the –c option, this procedure produces a data file without trailing blanks.
You can also use QUOTER interactively to reformat your data. You can access QUOTER interactively through the Administration Tool or, in character interfaces, the Data Dictionary. From the main menu, choose Utilities.