jll,
Actually, I'm talking about a slightly different solutiuon than linking and embedding. My basic theory is to store filenames instead and then to simply store the files separately from the database.
That way, you don't have to worry about additional overhead for the linking (which is somewhat problematic anyway as Paradox doesn't fully implement the full linking features. That work was done quickly for version 5.0 and, AFAIK, has never been properly reviewed or updated).
Instead, you simply add an alpha field long enough to hold a pathname. I usually use an 8.3 for this. I then store the actual files in a subdirectory of my DATA directory (where I keep all my tables) and save the shortened version of the actual ZIP/graphic file.
When implementing this, I usually use a two-stage approach.
First, I create a library function for selecting a filename, such as the systemSaveAs() method shown below:
Code:
method systemSaveAs( var strFileName String,
fbiInput fileBrowserInfo ) Logical
;----------------------------------------------------------------
; This routine lets the user choose a filename for a save
; operation. The parameters indicate, respectively, the location
; for the final file name and the options to be used with the
; fileBrowser() call.
;
; The return value indicates whether or not the user changed the
; file name from its initial value.
;----------------------------------------------------------------
var
strValue String ; Fully qualified file name
fbi FileBrowserInfo ; Structure for FileBrowser()
loRetval Logical ; value returned to caller.
dynParts Dynarray[] String ; Parts of selected file.
loRepeat Logical ; Variable for the while loop
endVar
; Initialize local variables
loRetval = TRUE ; assume user will choose a new name.
loRepeat = TRUE ; loop control variable
strValue = strFileName ; default selected file
; Initialize the file browser info structure
fbi = fbiInput
while loRepeat
loRetval = fileBrowser( strValue, fbi )
If loRetval then
; the user selected a file or the user selected an
; alias that no longer exists. So, we need to determine
; If the user actually selected a file.
; Start by building the final file name from the
; components of the fileBroswerInfo structure.
If fbi.Path <> "" then
strValue = fbi.Path + strValue
endIf
If fbi.Drive <> "" then
strValue = fbi.Drive + strValue
else
strValue = getAliasPath( fbi.alias ) + "\\" + strValue
endIf
splitFullFileName( strValue, dynParts )
; See if a bad alias was selected.
If dynParts[ "NAME" ] = "" then
msgStop( "Can't Use Alias", "The " + fbi.Alias +
" alias is not valid, presumeably because " +
"the folder or network drive no longer " +
"exists. Choose a different alias or " +
"folder." )
fbi.Alias = ":PRIV:"
else
loRepeat = FALSE
endIf
else
loRepeat = FALSE
endIf
endWhile
; Now, determine whether or not the user changed the file
; name
loRetval = NOT ( upper( FullName( strFileName ) ) =
upper( strValue ) )
If loRetval then
strFileName = strValue
endIf
dynParts.empty()
return loRetval
endMethod
Next, I create a caller routine for dealing with the actual file inquestion. For example, here's another routine I use for saving graphs:
Code:
method graphSave( uiTarget UIObject ) Logical
; ---------------------------------------------------------------
; This routine lets the user save a graph as a bitmap image.
;
; The parameter points to the graph to be saved and the return
; value indicates whether or not the data was successfully saved.
; ---------------------------------------------------------------
var
fbiXFile FileBrowserInfo ; data for systemSaveAs() function.
loRetval Logical ; Value returned to calling process.
strValue String ; Holds filenames
dynParts Dynarray[] String ; Holds parts of a filename.
grOutput Graphic ; Internal var used to create BMP
endVar
const
ERRTITLE = "Can't Save Graph" ; title for error dialogs
endConst
; initialize local vars
loRetval = TRUE
strValue = "MYGRAPH"
fbiXFile.Title = "Save Graph As"
; Note the constant that's used here. Though the documentation
; says the constant is called "browseOptPathMustExist," that
; generates a compiler error. A quick look at the table
; generated by enumRTLConstants() shows this is the constant
; to use instead.
fbiXFile.Options = browseOptPathMustExit
fbiXFile.AllowableTypes = fbBitmap
fbiXFile.Alias = ":PRIV:"
fbiXFile.NewFileOnly = True
fbiXFile.DefaultExt = "BMP"
; Call the SaveAs wrapper function
loRetval = systemSaveAs( strValue, fbiXFile )
if loRetval then
; Breakapart the user's selected file name
splitFullFileName( upper( strValue ), dynParts )
; Convert the graph to a bitmap.
message( "Copying graph to " + strValue + "..." )
setMouseShape( mouseWait )
uiTarget.action( editCopySelection )
grOutput.readFromClipboard()
loRetval = grOutput.writeToFile( strValue )
setMouseShape( mouseArrow )
If not loRetval then
errorShow( ERRTITLE,
"Data failed to copy; see details..." )
endIf
endIf
Message( "" )
return loRetval
endMethod
When calling this, I use something like this:
Code:
method pushButton(var eventInfo Event)
doDefault
libApp.graphSave( ChtData )
endMethod
Now, this is taken from a form with a global library variable and a graph object called chtData.
In your case, you'd probably want to rework graphSave() so it returns the name of the selected file to the calling process. Once you have that in hand, you'd basically store that into a string field.
Next, you'd add a trigger that would either execute WinZip with that value as an argument.
I don't have access to an example of that at the moment, but the above code should be enough to get you started. It was originally written for Paradox 8, but it should work in most other versions of Paradox.
Hope this helps...
-- Lance