COPYFILE Examples


Example:

 

Src

INIT

"source.txt"

 

Dst

INIT

"dest.txt"

 

.

 

 

 

  

COPYFILE

Src,Dst

// server to server

  

 

 

 

  

COPYFILE

"test.txt|127.0.0.1","server.txt"

// Sundm to server

  

 

 

 

  

COPYFILE

"server.txt","testdm.txt|127.0.0.1"

// server to Sundm

  

 

 

 

  

COPYFILE

"!client.txt","server.txt"

// PL/B Client to server

  

 

 

 

  

COPYFILE

"server.txt","!client.txt"

// server to PL/B Client

 

These examples show the various techniques for the use of the COPYFILE statement.

 

 

Size

FORM

10

BlksLeft

FORM

10

Position

FORM

10

String

DIM

80

Progress1

PROGRESS

 

Button1

Button

 

*

 

 

.Create the progress bar

.

 

 

  

CREATE

Progress1=2:5:10:30

  

ACTIVATE

Progress1

*

 

 

.Create a button to cancel the copy

.

 

 

 

CREATE

Button1=7:8:18:23,"Cancel"

 

ACTIVATE

Button1,Cancel,Szie

*

 

 

.Copy the file using 10 blocks

.

 

 

 

FINDFILE

"c:\temp\myfile.bin",FILESIZE=Size

 

DIV

"10",Size

*

 

 

.Initiate the copy

.

 

 

 

COPYFILE

"c:\temp\myfile.bin","x:myfile1.bin":

 

 

BlksLeft,BlockSize=Size

*

 

 

.Loop copying all blocks

.

 

 

 

LOOP

 

 

WHILE

(BlksLeft)

*

 

 

.Update the progress bar

.

 

 

 

MOVE

((10 - BlksLeft) * 10),Position

 

SETITEM

Progress1,0,Position

 

COPYNEXT BlksLeft

 

*

 

 

.Next block

.

 

 

 

REPEAT

 

*

 

 

.Copy complete

.

 

 

 

SETITEM

Progress1,0,100

 

STOP

 

*

 

 

.Cancel the copy

.

 

 

Cancel

 

 

 

COPYCANCEL

 

*

 

 

.Report the remaining block

.

 

 

 

COPYSTATUS

BlksLeft

 

PACK

String WITH "Copy canceled with ":

 

 

BlksLeft," blocks remaining."

 

ALERT

Caution,String,Size,"Copy Canceled"

.

 

 

 

STOP

 

 

This example shows an enhanced copyfile operation. The input file is copied using ten blocks while the progress bar is updated. If the Cancel button is clicked, the operation is aborted and the remaining block count displayed.



PL/B Language Reference CONST Example COS Example