DOWNLOAD PC FILE

DOWNLOAD

PC

[FILE] work-file-number

[VARIABLE] operand1

WRITE WORK COMMAND operand2

SYNC

ASYNC

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: CLOSE PC FILE | UPLOAD PC FILE | WRITE WORK FILE

Belongs to Function Group: Control of Work Files / PC Files


Function

This statement is used to transfer data from a UNIX platform to the PC.

See also the Natural Connection and Entire Connection documentation

Syntax Description

Operand Definition Table:

Operand Possible Structure Possible Formats Referencing Permitted Dynamic Definition
operand1 C S A G   A U N P I F B D T L C yes no
operand2 C S       A                     yes yes

When using the work file types ENTIRECONNECTION or TRANSFER, operand1 may neither be of Format C, nor G.

Syntax Element Description:

Syntax Element Description
work-file-number
Work File Number:

The work file number to be used. This number must correspond to one of the work file numbers for the PC as defined to Natural.

VARIABLE
Variable Format:

The records in the PC file will be written in variable format. Note that variable records cannot be converted to PC spreadsheet formats.

operand1
Field Specification:

With operand1 you specify the fields to be downloaded to the PC.

COMMAND
COMMAND Clause:

With the COMMAND clause, you can send PC commands (that is, any command that can be entered in the command line of Entire Connection on the PC) from the mainframe to the PC.

Entire Connection checks whether the command sent is valid or not. A command that cannot be recognized by the PC is rejected. In this case, Natural issues the error message that the downloaded command was rejected by the PC.

You can use the COMMAND clause, for example, to execute Entire Connection tasks from the mainframe. If you have the task DIR which lists PC directory information, you can initiate this directly out of your Natural program on the mainframe with the following statement:

DOWNLOAD PC FILE 7 COMMAND 'DIR'

In Example 2 below, the COMMAND clause is used to define the name of the PC file that is to receive the downloaded data. In this way, you can avoid prompting for the name of the file.

operand2
COMMAND Specification:

With operand2, you specify the DOS command or Entire Connection task that is to be executed on the PC. operand2 must be an alphanumeric constant or variable.

SYNC
SYNC Option:

With SYNC, you specify that the PC returns control to Natural after executing and terminating COMMAND. SYNC can be used, for example, to ensure that the command SET PCFILE has been executed before a file transfer starts.

ASYNC
ASYNC Option:

With ASYNC, you specify that the PC immediately returns control to Natural, regardless of whether the execution of COMMAND has terminated or not.

Examples

Example 1 - Use of DOWNLOAD PC FILE Statement

The following program demonstrates the use of the DOWNLOAD PC FILE statement. The data is first selected and then downloaded to the PC by using Work File 7.

** Example 'PCDOEX1': DOWNLOAD PC FILE                                  
**                                                                      
** NOTE: Example requires that Natural Connection is installed.         
************************************************************************
DEFINE DATA LOCAL                                                       
01 PERS VIEW OF EMPLOYEES                                               
  02 PERSONNEL-ID                                                       
  02 NAME                                                               
  02 CITY                                                               
END-DEFINE                                                              
*                                                                       
FIND PERS WITH CITY = 'NEW YORK'                     /* Data selection         
  DOWNLOAD PC FILE 7 CITY NAME PERSONNEL-ID    /* Data download  
END-FIND                                                                
END

Output of Program PCDOEX1:

When you run the program, a window appears in which you specify the name of the PC file into which the data is to be downloaded. The data is then downloaded to the PC.

Example 2 - Use of COMMAND Clause

The following program demonstrates the use of the COMMAND clause in the DOWNLOAD PC FILE statement. The name of the receiving PC file is first defined. Then the data is selected and downloaded to this file.

** Example 'PCDOEX2': DOWNLOAD PC FILE                                  
**                                                                      
** NOTE: Example requires that Natural Connection is installed.         
************************************************************************
DEFINE DATA LOCAL                                                       
01 PERS VIEW OF EMPLOYEES                                               
  02 PERSONNEL-ID                                                       
  02 NAME                                                               
  02 CITY                                                               
01 CMD (A80)                                   /* Variable for transfer 
END-DEFINE                                     /* of the PC command     
*                                                                       
MOVE 'SET PCFILE 7 DOWN DATA PERS.NCD' TO CMD  /* PC command to define  
*                                                                       
DOWNLOAD PC FILE 6 COMMAND CMD                 /* Command download
*                                                                       
FIND PERS WITH CITY = 'NEW YORK'               /* Data selection   
  DOWNLOAD PC FILE 7 CITY NAME PERSONNEL-ID    /* Data download         
END-FIND                                                                
END

Note:
The PC file number in two successive DOWNLOAD PC FILE statements must be different.

Output of Program PCDOEX2:

When you run the program, the data is downloaded to the PC file that was specified in the program. A window does not appear.