home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2002 June
/
PCWorld_2002-06_cd.bin
/
Software
/
Komercni
/
xbase
/
express
/
exd17208.r04
/
exp17
/
Samples
/
Xdemo4.prg
< prev
next >
Wrap
Text File
|
2002-01-30
|
5KB
|
273 lines
/*
╓─────────────────────────────────────────────────────────────────╖
║ Program..: XDEMO4.PRG ║
║ Author...: Roger J. Donnay ║
║ Notice...: (c) DONNAY Software Designs 1987-1998 ║
║ Date.....: Jun 26, 1999 ║
║ Notes....: eXPress Demo Program #4 (Clipper conversion) ║
╙─────────────────────────────────────────────────────────────────╜
This sample program demonstrates how an existing Clipper application
can be converted from Text-Based to Gui-Based by including the
EXPRESS.CH header file and linking with the DCLIPX.LIB library.
*/
#include "express.ch"
MEMVAR promptList
/* ----------------------- */
FUNCTION XDemo_4 ( oDialog, lMDI, lGui )
LOCAL nChoice := 1, lSaveGui := DC_Gui(), cSaveScrn, oAppWindow, ;
oCrt, aDemo, oParent, nCol, nRow
DEFAULT lMDI := .f.
DEFAULT lGui := .t.
SET PATH TO ..\DATA
IF !lGui
oAppWindow := SetAppWindow()
DC_Gui(.f.)
// Create XbpCRT object
oCrt := XbpCrt():New( oDialog:drawingArea, NIL, { 0, 0 }, 25, 80 )
oCrt:FontWidth := 8
oCrt:FontHeight := 12
oCrt:FontName := "Alaska Crt"
oCrt:Title := "eXPress++ Demo 4 (Text)"
oCrt:setInputFocus := {||SetAppWindow(oCrt)}
oCrt:Create()
// Init Presentation Space
oCrt:PresSpace()
// XbpCrt gets active window and output device
SetAppWindow ( oCrt )
ELSE
DC_Gui(.t.)
ENDIF
IF Select('COLLECT') = 0
USE COLLECT VIA DBFNTX NEW SHARED
ELSE
dbSelectArea('COLLECT')
ENDIF
DO WHILE .t.
IF !lGui
DC_Gui(.f.)
ENDIF
SetColor('W+/N')
CLS
SetColor('N/W,W+/B')
@ 5,20 CLEAR TO 19,60
@ 5,20 TO 19,60
@ 7,25 PROMPT 'E = Edit '
@ 9,25 PROMPT 'B = Browse '
@11,25 PROMPT 'U = Utilities '
@13,25 PROMPT 'F = Field List '
@15,25 PROMPT 'S = Shell to DOS '
@17,25 PROMPT 'X = Exit '
MENU TO nChoice
DO CASE
CASE nChoice = 1
EditRec()
CASE nChoice = 2
BrowseRec()
CASE nChoice = 3
Utilities()
CASE nChoice = 4
FieldList()
CASE nChoice = 5
RUN COMMAND.COM
CASE nChoice = 6 .OR. nChoice = 0
EXIT
ENDCASE
ENDDO
DC_Gui(lSaveGui)
IF Valtype(oCrt) = 'O' .AND. oCrt:status()>0
oCrt:Destroy()
SetAppWindow( oAppWindow )
ENDIF
RETURN nil
/* --------------------- */
STATIC FUNCTION EditRec
LOCAL Getlist := {}, GetOptions, cDescrip, cType, cSubType, ;
dDateOrig, cLocation, cBitmap1, cBitmap2, lOriginal, ;
nForSale, cCondition, dDateAcq, nOrigPrice, nApprValue, ;
cComments
cDescrip := COLLECT->descrip
cType := COLLECT->type
cSubType := COLLECT->sub_type
dDateOrig := COLLECT->date_orig
dDateAcq := COLLECT->date_acqu
nOrigPrice := COLLECT->orig_price
nApprValue := COLLECT->appr_value
cCondition := COLLECT->condition
nForSale := COLLECT->for_sale
cBitmap1 := COLLECT->bitmap1
cBitmap2 := COLLECT->bitmap2
cLocation := COLLECT->location
cComments := COLLECT->comments
lOriginal := COLLECT->original
SetColor('W+/N')
CLS
SET DATE FORMAT TO 'mm/dd/yyyy'
SetColor('N/W,W+/B')
@ 5,5 CLEAR TO 20,75
@ 5,5 TO 20,75
@ 7,10 SAY ' Description' GET cDescrip
@ 9,10 SAY ' Type' GET cType
@10,10 SAY ' Sub-Type' GET cSubType
@11,10 SAY ' Location' GET cLocation
@13,10 SAY ' Original Date' GET dDateOrig PICT '99/99/9999'
@14,10 SAY ' Date Acquired' GET dDateAcq PICT '99/99/9999'
@16,10 SAY ' Original Price' GET nOrigPrice
@17,10 SAY 'Appraised Value' GET nApprValue
@13,40 SAY ' Bit Map 1' GET cBitMap1
@14,40 SAY ' Bit Map 2' GET cBitMap2
@16,40 SAY ' For Sale?' GET nForSale
@16,60 SAY '0,1,2'
@17,40 SAY ' Condition' GET cCondition
READ
RETURN nil
/* --------------------- */
STATIC FUNCTION BrowseRec
SetColor('N/W,W+/B')
DbEdit()
RETURN nil
/* --------------------- */
STATIC FUNCTION Utilities
LOCAL nChoice := 2
SetColor('W+/N')
CLS
SetColor('N/W,W+/B')
@ 5,20 CLEAR TO 17,60
@ 5,20 TO 17,60
@ 7,25 PROMPT 'P = Pack '
@ 9,25 PROMPT 'B = Backup '
@11,25 PROMPT 'C = Copy '
@13,25 PROMPT 'I = Import '
@15,25 PROMPT 'X = Exit '
MENU TO nChoice
DO CASE
CASE nChoice = 1
Alert('This is my PACK routine')
CASE nChoice = 2
Alert('This is my BACKUP routine')
CASE nChoice = 3
Alert('This is my COPY routine')
CASE nChoice = 4
Alert('This is my IMPORT routine')
ENDCASE
RETURN nil
/* --------------------- */
STATIC FUNCTION FieldList
LOCAL aStru := dbStruct(), aFieldNames := {}, i, nChoice
FOR i := 1 TO Len(aStru)
AAdd( aFieldNames, Pad(aStru[i,1],12) + Pad(aStru[i,2],4) + ;
Str(aStru[i,3],4) + Str(aStru[i,4],4) )
NEXT
SetColor('W+/N')
CLS
SetColor('N/W,W+/B')
@ 8,10 CLEAR TO 20,40
@ 8,10 TO 20,40
nChoice := Achoice( 9, 11, 19, 39, aFieldNames )
RETURN nChoice