PROP:ProgressEvents

Top  Previous  Next

PROP:ProgressEvents is a property of a FILE that generates events to the currently open window during a BUILD or PACK operation (WRITE ONLY). This property is driver-dependent, and currently only supported for Clarion and Topspeed files.

Assigning a value of zero (0) turns off event generation for the next BUILD or PACK statement executed, while assigning any other value (valid range--1 to 100) turns on event generation. Out of range assignments are treated as follows: a negative number is treated as one (1), and any value greater than one hundred (100) is treated as one hundred (100). The larger the value assigned, the more events are generated and the slower the BUILD or PACK will progress.

Events generated are: EVENT:BuildFile, EVENT:BuildKey, and EVENT:BuildDone. It is not valid to make any calls to the FILE being built except to query its properties, call NAME(file), or CLOSE(file) (which aborts the process and is not recommended). Issuing a CYCLE statement in response to any of the events generated (except EVENT:BuildDone) cancels the operation.

PROP:CurrentKey may be used to get a reference to the current key being built, then PROP:Label may be used to retrieve the key's label for display to the user.

PROP:Completed is a property of a FILE that returns the percentage completed of the re-build during a BUILD or PACK operation for which PROP:ProgressEvents has been turned on. Returns zero (0) if the file driver does not know how much of the BUILD or PACK has been done. (READ ONLY)

Example:

 PROGRAM

 

 MAP

  CheckError(), bool

 END

 

Window WINDOW('Event:BuildDone Example'),AT(,,209,76),|

      FONT('MS SansSerif',8,,FONT:regular,CHARSET:ANSI), |

      CENTER,SYSTEM,GRAY,DOUBLE

      BUTTON('Create file'),AT(3,5,57,22),USE(?Button:CreateFile)

      BUTTON('Build File (With Events)'),AT(71,7,84,22),USE(?Button:Build)

    END

 

MyTPS     FILE, DRIVER('TOPSPEED'), CREATE, RECLAIM, NAME('MyTPS.tps'),PRE(MYT)

PK_IDKey   KEY(MYT:ID), PRIMARY

K_DescKey  KEY(MYT:Description), DUP, NOCASE

Record     RECORD

ID          LONG

Description CSTRING(256)

          END

         END

 

COUNT   LONG, AUTO

CODE

 OPEN(Window)

 ACCEPT

 CASE EVENT()

 OF Event:Accepted

  CASE FIELD()

  OF ?Button:CreateFile

  ?Button:CreateFile{Prop:Disable} = TRUE

  CREATE(MyTPS)

  IF CheckError()

   POST(Event:CloseWindow)

   CYCLE

  END

  OPEN(MyTPS)

  IF CheckError()

   POST(Event:CloseWindow)

   CYCLE

  END

  STREAM(MyTPS)

  LOOP Count = 1 to 100

   CLEAR(MyTPS)

   MYT:ID = Count

   MYT:Description = 'Desc#: ' & Count

   APPEND(MyTPS)

   IF CheckError() THEN BREAK.

  END

  FLUSH(MyTPS)

  IF MESSAGE('Do you want to create a duplicate record?', 'Create duplicate',|

             Icon:Question, Button:Yes + Button:No,Button:Yes) = Button:Yes

   CLEAR(MyTPS)

   MYT:ID = 1

   MYT:Description = 'Desc#: ' & 1

   APPEND(MyTPS)

  END

  CLOSE(MyTPS)

  ?Button:CreateFile{Prop:Disable} = FALSE

  OF ?Button:Build

  ?Button:Build{Prop:Disable} = TRUE

  MyTPS{Prop:ProgressEvents} = 100

  SEND(MyTPS, 'FULLBUILD=on')

  BUILD(MyTPS)

  IF CheckError() THEN POST(Event:CloseWindow).

 END

 OF Event:BuildFile OROF Event:BuildKey

 OF Event:BuildDone

  IF CheckError()

   MESSAGE('BUILD FAILED !', 'BUILD', Icon:Hand)

  ELSE

   MESSAGE('BUILD OK', 'BUILD', Icon:Asterisk)

  END

  ?Button:Build{Prop:Disable} = FALSE

 END

END

 

!------------------------------------------------

CheckError          FUNCTION()

CODE

IF ERRORCODE()

 MESSAGE(ERROR(), 'CheckError: ' & ERRORCODE(), Icon:Hand)

 RETURN TRUE

END

RETURN FALSE