home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
SK0993.ZIP
/
MAKE_LIB.SC
< prev
next >
Wrap
Text File
|
1993-07-21
|
7KB
|
241 lines
; Make_lib.sc
CLEAR
MESSAGE "Creating MemoBlob Library"
libname = "MemoBlob"
; Create the library.
; If there's an old one, overwrite it.
CREATELIB libname
;---------------------------------------------------
; ViewBLOb()
; This procedure works around the problem of only
; being able to define one default BLOb editor. It
; looks for the existance of an A3 field named
; BLObType. If it finds the field, it uses it to
; determine which program should be called to edit
; the BLOb. It then writes the BLOb field contents
; to a temporary file and calls the appropriate
; program. The name of the temp file is passed to
; the program on the command line. Upon returning
; from the BLOb editor program, the procedure then
; reads the temp file contents into variable (they
; may have changed) and stores them in the field.
; This version is configured to call one of three
; different programs. You'll probably need to modify
; it to work with the BLOb editors on your system.
; The procedure is designed to be called from a
; SETKEY macro which redefines the FieldView key(s).
; Since two keystrokes (Ctrl-F and Alt-F5) get into
; FieldView you need two SETKEYs:
; SETKEY "FIELDVIEW" READLIB
;"D:\\PX40DATA\\BLObS\\MemoBlob" ViewBLOb ViewBLOb()
; SETKEY "F35" READLIB
;"D:\\PX40DATA\\BLObS\\MemoBlob" ViewBLOb ViewBLOb()
; (These are included in a script "KeyMacs.sc")
;---------------------------------------------------
PROC ViewBLOb()
PRIVATE blobrec, temp.BLOb
IF NIMAGES() = 0 THEN
QUIT
ENDIF
IF SUBSTR(FIELDTYPE(),1,1) <> "B" THEN
FIELDVIEW
QUIT
ENDIF
IF SYSMODE() <>"CoEdit" THEN
; Need to be able to assign BLOb field
QUIT "Go into CoEdit mode to change BLOb fields"
ENDIF
COPYTOARRAY blobrec
IF NOT ISASSIGNED(blobrec["BLObType"]) THEN
; If there is no BLObType field
FIELDVIEW ; Call default BLOb editor
ELSE
MESSAGE "Loading BLOb editor"
SWITCH
CASE UPPER([BLObType]) = "PCX":
; Write to temp file
FILEWRITE BINARY "PXTEMP.PCX"
FROM blobrec[FIELD()]
RUN "PICEM PXTEMP.PCX >NUL" ; Run Picem
; Read file back into a variable
FILEREAD BINARY "PXTEMP.PCX" TO temp.BLOb
; Write var contents to BLOb
[] = temp.BLOb
CASE UPPER([BLObType]) = "DOC":
FILEWRITE BINARY "PXTEMP.DOC"
FROM blobrec[FIELD()]
RUN "C:\\WORD\\WORD PXTEMP.DOC"
FILEREAD BINARY "PXTEMP.DOC" TO temp.BLOb
[] = temp.BLOb
CASE UPPER([BLObType]) = "WQ1":
FILEWRITE BINARY "PXTEMP.WQ1"
FROM blobrec[FIELD()]
RUN "C:\\QPRO\\Q PXTEMP.WQ1"
FILEREAD BINARY "PXTEMP.WQ1" TO temp.BLOb
[] = temp.BLOb
OTHERWISE:
QUIT "No BLOb editor defined for BLObType"
ENDSWITCH
ENDIF
ENDPROC
WRITELIB libname ViewBLOb
RELEASE PROCS ViewBLOb
;---------------------------------------------------
; AssignBLOb()
; This procedure allows the user to copy a file into
; a BLOb field. A dialog box is presented allowing
; the user to choose a directory and file name. The
; procedure can be called with a SETKEY macro.
;---------------------------------------------------
PROC AssignBLOb()
PRIVATE file.a, temp.BLOb
IF NIMAGES() = 0 THEN ; Is cursor in a field?
QUIT
ENDIF
; Is this a BLOb field?
IF SUBSTR(FIELDTYPE(),1,1) <> "B" THEN
QUIT "This is not a BLOb field"
ENDIF
; Need to be able to assign BLOb field
IF SYSMODE() <>"CoEdit" THEN
QUIT "You must be in CoEdit to change BLOb fields"
ENDIF
; Display Dialog Box to get file
file.a = DlgSelectFile()
IF file.a <> "" THEN
FILEREAD BINARY file.a TO temp.BLOb
[] = temp.BLOb
ENDIF
ENDPROC
WRITELIB libname AssignBLOb
RELEASE PROCS AssignBLOb
; **************************************************
; DlgTblsL
; Copyright (c) 1992 Martin W. Rudy
; All Rights Reserved
; This program can be used/copied/modified without
; charge provided this copyright notice is included
; without change, and that any accompanying
; documentation includes "Portions of this code
; Copyright (c) 1992, Martin W. Rudy All Rights
; Reserved"
; **************************************************
; This dialog box allows you to select tables from
; a picklist and specify the directory using an
; ACCEPT control element.
;
; MODIFICATIONS: This dialog box has been remodeled
; to allow the user to select a FILE from the
; picklist. The dialog box is wider than the
; original to accomodate 4 columns of file names.
; A few other things were moved around and some
; names (variables, tags & the proc itself) were
; changed. The event proc was not changed except to
; make it reference the correct tags & variables.
; - SK 11/10/92
PROC DlgSelectFile()
PRIVATE dirname, msg, acceptcancel
dirname = DIRECTORY()
msg = ""
SHOWDIALOG "Choose File"
PROC "PickListProc"
TRIGGER "SELECT","UPDATE"
@ 5,5
HEIGHT 13 WIDTH 64
STYLE ATTRIBUTE 4+112
@ 2,13 ?? msg
STYLE
LABEL @ 1,0 "~D~irectory: " FOR "dirnameTAG"
ACCEPT @ 1,13
WIDTH 48
"A40"
TAG "dirnameTAG"
TO dirname
PICKFILE @ 3,1
HEIGHT 5
WIDTH 59
COLUMNS 4
dirname
TAG "pickfileTAG"
TO pickfile1
PUSHBUTTON @ 9,20
WIDTH 10
"OK"
OK DEFAULT
VALUE "OK"
TAG "OK"
TO acceptcancel
PUSHBUTTON @ 9,33
WIDTH 10
"Cancel"
CANCEL
VALUE "Cancel"
TAG "Cancel"
TO acceptcancel
ENDDIALOG
IF retval THEN
RETURN dirname + pickfile1
ELSE
RETURN ""
ENDIF
ENDPROC
WRITELIB libname DlgSelectFile
RELEASE PROCS DlgSelectFile
PROC PickListProc(TriggerType, TagValue,
EventValue, ElementValue)
SWITCH
CASE TriggerType = "SELECT" :
IF TagValue = "pickfileTAG" THEN
ACCEPTDIALOG
ENDIF
CASE TriggerType = "UPDATE" :
IF TagValue = "dirnameTAG" THEN
IF dirname<>CONTROLVALUE("dirnameTAG") THEN
IF DIREXISTS(EventValue) = 1 THEN
msg = ""
IF SUBSTR(EventValue,LEN(EventValue),1)=
"\\" THEN
dirname = EventValue
ELSE
dirname = EventValue + "\\"
ENDIF
ELSE
msg = "Directory doesn't exist!"
BEEP
dirname = EventValue
ENDIF
REFRESHDIALOG
RETURN False
ENDIF
ENDIF
ENDSWITCH
RETURN True
ENDPROC
WRITELIB libname PickListProc
RELEASE PROCS PickListProc