home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / SK0993.ZIP / MAKE_LIB.SC < prev    next >
Text File  |  1993-07-21  |  7KB  |  241 lines

  1. ; Make_lib.sc
  2. CLEAR
  3. MESSAGE "Creating MemoBlob Library"
  4. libname = "MemoBlob"
  5. ; Create the library.
  6. ; If there's an old one, overwrite it.
  7. CREATELIB libname
  8.  
  9. ;---------------------------------------------------
  10. ; ViewBLOb()
  11. ; This procedure works around the problem of only
  12. ; being able to define one default BLOb editor. It 
  13. ; looks for the existance of an A3 field named 
  14. ; BLObType.  If it finds the field, it uses it to 
  15. ; determine which program should be called to edit 
  16. ; the BLOb. It then writes the BLOb field contents 
  17. ; to a temporary file and calls the appropriate 
  18. ; program. The name of the temp file is passed to 
  19. ; the program on the command line. Upon returning 
  20. ; from the BLOb editor program, the procedure then
  21. ; reads the temp file contents into variable (they 
  22. ; may have changed) and stores them in the field.
  23. ; This version is configured to call one of three 
  24. ; different programs. You'll probably need to modify
  25. ; it to work with the BLOb editors on your system. 
  26. ; The procedure is designed to be called from a 
  27. ; SETKEY macro which redefines the FieldView key(s).
  28. ; Since two keystrokes (Ctrl-F and Alt-F5) get into
  29. ; FieldView you need two SETKEYs:
  30. ; SETKEY "FIELDVIEW" READLIB 
  31. ;"D:\\PX40DATA\\BLObS\\MemoBlob" ViewBLOb ViewBLOb()
  32. ; SETKEY "F35" READLIB
  33. ;"D:\\PX40DATA\\BLObS\\MemoBlob" ViewBLOb ViewBLOb()
  34. ; (These are included in a script "KeyMacs.sc")
  35. ;---------------------------------------------------
  36. PROC ViewBLOb()
  37. PRIVATE blobrec, temp.BLOb
  38.    
  39.  IF NIMAGES() = 0 THEN  
  40.    QUIT
  41.  ENDIF   
  42.    
  43.  IF SUBSTR(FIELDTYPE(),1,1) <> "B" THEN  
  44.    FIELDVIEW                                
  45.    QUIT
  46.  ENDIF
  47.    
  48.  IF SYSMODE() <>"CoEdit" THEN
  49.    ; Need to be able to assign BLOb field
  50.    QUIT "Go into CoEdit mode to change BLOb fields"
  51.  ENDIF
  52.    
  53.  COPYTOARRAY blobrec
  54.  IF NOT ISASSIGNED(blobrec["BLObType"]) THEN
  55.    ; If there is no BLObType field
  56.    FIELDVIEW       ; Call default BLOb editor
  57.  ELSE   
  58.    MESSAGE "Loading BLOb editor"
  59.    SWITCH
  60.      CASE UPPER([BLObType]) = "PCX":
  61.        ; Write to temp file
  62.        FILEWRITE BINARY "PXTEMP.PCX"
  63.          FROM blobrec[FIELD()]
  64.        RUN "PICEM PXTEMP.PCX >NUL"     ; Run Picem
  65.        ; Read file back into a variable
  66.        FILEREAD BINARY "PXTEMP.PCX" TO temp.BLOb
  67.        ; Write var contents to BLOb
  68.        [] = temp.BLOb
  69.      CASE UPPER([BLObType]) = "DOC":
  70.        FILEWRITE BINARY "PXTEMP.DOC"
  71.          FROM blobrec[FIELD()]
  72.        RUN "C:\\WORD\\WORD PXTEMP.DOC"
  73.        FILEREAD BINARY "PXTEMP.DOC" TO temp.BLOb
  74.        [] = temp.BLOb
  75.      CASE UPPER([BLObType]) = "WQ1":
  76.        FILEWRITE BINARY "PXTEMP.WQ1"
  77.          FROM blobrec[FIELD()]
  78.        RUN "C:\\QPRO\\Q PXTEMP.WQ1"
  79.        FILEREAD BINARY "PXTEMP.WQ1" TO temp.BLOb
  80.        [] = temp.BLOb
  81.      OTHERWISE:
  82.        QUIT "No BLOb editor defined for BLObType"
  83.    ENDSWITCH
  84.  ENDIF 
  85.    
  86. ENDPROC
  87. WRITELIB libname ViewBLOb
  88. RELEASE PROCS ViewBLOb
  89.  
  90. ;---------------------------------------------------
  91. ; AssignBLOb()
  92. ; This procedure allows the user to copy a file into
  93. ; a BLOb field. A dialog box is presented allowing
  94. ; the user to choose a directory and file name. The
  95. ; procedure can be called with a SETKEY macro.
  96. ;---------------------------------------------------
  97. PROC AssignBLOb()
  98. PRIVATE file.a, temp.BLOb
  99.    
  100.  IF NIMAGES() = 0 THEN       ; Is cursor in a field?
  101.    QUIT
  102.  ENDIF   
  103.  ; Is this a BLOb field?
  104.  IF SUBSTR(FIELDTYPE(),1,1) <> "B" THEN
  105.    QUIT "This is not a BLOb field"
  106.  ENDIF
  107.    
  108.  ; Need to be able to assign BLOb field
  109.  IF SYSMODE() <>"CoEdit" THEN
  110.   QUIT "You must be in CoEdit to change BLOb fields"
  111.  ENDIF
  112.  
  113.  ; Display Dialog Box to get file
  114.  file.a = DlgSelectFile()
  115.  IF file.a <> "" THEN
  116.    FILEREAD BINARY file.a TO temp.BLOb
  117.    [] = temp.BLOb
  118.  ENDIF
  119.  
  120. ENDPROC
  121. WRITELIB libname AssignBLOb
  122. RELEASE PROCS AssignBLOb
  123.  
  124. ; **************************************************
  125. ; DlgTblsL
  126. ; Copyright (c) 1992   Martin W. Rudy
  127. ; All Rights Reserved
  128. ; This program can be used/copied/modified without
  129. ; charge provided this copyright notice is included
  130. ; without change, and that any accompanying 
  131. ; documentation includes "Portions of this code
  132. ; Copyright (c) 1992, Martin W. Rudy  All Rights
  133. ; Reserved"
  134. ; **************************************************
  135.  
  136. ; This dialog box allows you to select tables from
  137. ; a picklist and specify the directory using an
  138. ; ACCEPT control element.             
  139. ;
  140. ; MODIFICATIONS: This dialog box has been remodeled
  141. ; to allow the user to select a FILE from the
  142. ; picklist.  The dialog box is wider than the
  143. ; original to accomodate 4 columns of file names. 
  144. ; A few other things were moved around and some
  145. ; names (variables, tags & the proc itself) were
  146. ; changed. The event proc was not changed except to
  147. ; make it reference the correct tags & variables.
  148. ; - SK 11/10/92
  149.  
  150. PROC DlgSelectFile()
  151. PRIVATE dirname, msg, acceptcancel
  152.  
  153.  dirname = DIRECTORY()
  154.  msg     = ""
  155.  
  156.  SHOWDIALOG "Choose File"
  157.    PROC "PickListProc"
  158.    TRIGGER "SELECT","UPDATE"
  159.    @ 5,5
  160.    HEIGHT 13 WIDTH 64
  161.    STYLE ATTRIBUTE 4+112
  162.    @ 2,13 ?? msg
  163.    STYLE
  164.    LABEL @ 1,0 "~D~irectory: " FOR "dirnameTAG"
  165.  
  166.    ACCEPT @ 1,13
  167.      WIDTH 48
  168.      "A40"
  169.      TAG "dirnameTAG"
  170.      TO dirname
  171.  
  172.    PICKFILE @ 3,1
  173.      HEIGHT 5
  174.      WIDTH 59
  175.      COLUMNS 4
  176.      dirname
  177.      TAG "pickfileTAG"
  178.      TO  pickfile1
  179.  
  180.    PUSHBUTTON @ 9,20
  181.      WIDTH 10
  182.      "OK"
  183.      OK DEFAULT
  184.      VALUE "OK"
  185.      TAG "OK"
  186.      TO acceptcancel
  187.  
  188.    PUSHBUTTON @ 9,33
  189.      WIDTH 10
  190.      "Cancel"
  191.      CANCEL
  192.      VALUE "Cancel"
  193.      TAG "Cancel"
  194.      TO acceptcancel
  195.  
  196.  ENDDIALOG
  197.  
  198.  IF retval THEN
  199.    RETURN dirname + pickfile1
  200.  ELSE
  201.    RETURN ""
  202.  ENDIF
  203.  
  204. ENDPROC
  205. WRITELIB libname DlgSelectFile
  206. RELEASE PROCS DlgSelectFile
  207.  
  208. PROC PickListProc(TriggerType, TagValue,
  209.                   EventValue, ElementValue)
  210.   SWITCH
  211.     CASE TriggerType = "SELECT" :
  212.       IF TagValue = "pickfileTAG" THEN
  213.         ACCEPTDIALOG
  214.       ENDIF
  215.     CASE TriggerType = "UPDATE" :
  216.       IF TagValue = "dirnameTAG" THEN
  217.         IF dirname<>CONTROLVALUE("dirnameTAG") THEN
  218.           IF DIREXISTS(EventValue) = 1 THEN
  219.             msg = ""
  220.             IF SUBSTR(EventValue,LEN(EventValue),1)=
  221.                "\\" THEN
  222.               dirname = EventValue
  223.             ELSE
  224.               dirname = EventValue + "\\"
  225.             ENDIF
  226.           ELSE
  227.             msg = "Directory doesn't exist!"
  228.             BEEP
  229.             dirname = EventValue
  230.           ENDIF
  231.           REFRESHDIALOG
  232.           RETURN False
  233.         ENDIF
  234.       ENDIF
  235.   ENDSWITCH
  236.   RETURN True
  237. ENDPROC
  238. WRITELIB libname PickListProc
  239. RELEASE PROCS PickListProc
  240.  
  241.