Progress
Programming
Handbook


Using QUOTER to Format Data

The QUOTER utility formats character data in a file to the standard format so it can be used by a Progress procedure. By default, QUOTER does the following:

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 Progress input format:

Operating System
Syntax
UNIX
Windows
quoter input-file-name
  [ > output-file-name
   | -d character
   | -c startcol-stopcol
  ] ...

PARAMETERS
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 looked like the following example:

p-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 Table 7–3 to run QUOTER from the Procedure Editor:

Table 7–3: Quoter Examples 
Operating System

Using Quoter—Examples
Windows
DOS quoter p-dat12.d >p-dat12.q
UNIX
UNIX quoter p-datf12.d >p-datf12.q

In Figure 7–8, p-datfl2.d is the name of the data file you supply to QUOTER while p-datfl2.q is the name of the file in which you want to store QUOTER’s output.

Figure 7–8: How QUOTER Prepares a File

The p-datfl2.q file contains the QUOTER output:

p-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 a Progress procedure.

What if each of the field values in your data file is not on a separate line (unlike p-datfl2.d) and without quotes (unlike p-datf1.d)? That is, your data file looks like p-datfl3.d:

p-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 p-chgin3.p does that.

p-chgin3.p
       DEFINE VARIABLE data AS CHARACTER FORMAT "x(78)". 
/*1*/  OS-COMMAND SILENT quoter p-datfl3.d > p-datfl3.q. 
/*2*/  INPUT FROM p-datfl3.q NO-ECHO. 
       REPEAT: 
/*3*/      CREATE customer. 
/*4*/      SET data WITH NO-BOX NO-LABELS NO-ATTR-SPACE WIDTH 80. 
           cust-num = INTEGER(SUBSTRING(data,1,2)). 
           name = SUBSTRING(data,4,17). 
/*5*/      sales-rep = 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 p-datfl3.d file and produces data that looks like the following example:
  2. p-datf13.q
    "90 Wind Chill Hockey  BBB" 
    "91 Low Key Checkers   DKP" 
    "92 Bing’s Ping Pong   SLS" 
    

  3. The INPUT FROM statement redirects the input stream to get input from the p-datfl3.q file.
  4. The CREATE statement creates an empty customer record.
  5. The SET statement uses the first quoted line in the p-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.
  6. 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 Figure 7–9.
  7. Figure 7–9: Extracting QUOTER Input with SUBSTRING

    Because Progress assumes that all the data in the p-datfl3.q file is character data, you must use the INTEGER function to convert the cust–num data to an integer value.

  8. The INPUT CLOSE statement closes the input stream coming from the p-datfl3.q file and redirects the input stream to the terminal.
  9. 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 p-datfl4.d:

p-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 p-chgin4.p reads the comma-separated data from p-datfl4.d:

p-chgin4.p
OS-COMMAND SILENT quoter -d , p-datfl4.d >p-datfl4.q. 
INPUT FROM p-datfl4.q NO-ECHO. 
REPEAT: 
    CREATE customer. 
    SET cust-num name sales-rep. 
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 p-datfl4.q:

p-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 Progress 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 p-datfl5.d:

p-datf15.d
90 Wind Chill Hockey BBB 
91 Low Key Checkers  DKP 
92 Bing’s Ping Pong  SLS 

The procedure p-chgin5.p uses this data file to create customer records:

p-chgin5.p
OS-COMMAND SILENT quoter -c 1-2,4-20,22-24 p-datfl5.d >p-datfl5.q. 
INPUT FROM p-datfl5.q NO-ECHO. 
REPEAT: 
    CREATE customer. 
    SET cust-num name sales-rep. 
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.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095