Hello Carl,
I am not sure of a way in programming to save an
Actual Retrieve spec that shows up in the Spec Manager in 1.1.4, But I did come up with a way to save the values at the Retrieve spec so you can re-use them.
Put two buttons on your form. One to Save the Spec and one to Load the spec. Then comes the following program.
** PROGRAMMING SECTION: [ GLOBAL CODE ] [] **
Stat gsElementList as String
Stat gsButtonList as String
Subroutine GetSetRetrieve(vWhich as String, Var vValues as String)
Var vLoop as Int
Var vCnt as Int
Var vName as String
Var vPart as String
vLoop = 1
If vWhich = "GET" Then
{
vValues = ""
vCnt = @CountStringArray(gsElementList)
While vLoop <= vCnt
{
vName = @AccessStringArray(gsElementList, vLoop)
SetThisElement(vName)
If ((@ElementType(ThisElement) < 1009) And (@IsBlank(ThisElement) = 0)) Then
{
vValues = vValues + @ElementName(ThisElement) + "=" + ThisElement + "^"
}
UnSetThisElement()
vLoop = vLoop + 1
}
}
Else If vWhich = "SET" Then
{
SetStringArraySeparator("^")
vCnt = @CountStringArray(vValues)
While vLoop <= vCnt
{
vPart = @AccessStringArray(vValues, vLoop)
If vPart <> "" Then
{
vName = Split(vPart, "=")
SetThisElement(vName)
ThisElement = vPart
UnSetThisElement()
}
vLoop = vLoop + 1
}
RestoreStringArraySeparator()
}
End Subroutine
Subroutine SetVisibility(vElements as String, State as Int)
Var vLoop as Int
Var vCnt as Int
Var vName as String
vLoop = 1
vCnt = @CountStringArray(vElements)
While vLoop <= vCnt
{
vName = @AccessStringArray(vElements, vLoop)
SetThisElement(vName)
Visibility(ThisElement, State)
UnSetThisElement()
vLoop = vLoop + 1
}
End Subroutine
gsElementList = @StringArrayElementList()
gsButtonList = "Load;Save"
** PROGRAMMING SECTION: [Main Form] [On Form Entry] **
SetVisibility(gsButtonList, 0)
** PROGRAMMING SECTION: [Main Form] [On Retrieve Spec Open] **
SetVisibility(gsButtonList, 1)
** PROGRAMMING SECTION: [Load] [On Element Entry] **
Var vName as String
Var vRetValues as String
Var vSpecs as String
Var vSuccess as Int
vSpecs = @GlobalValue("CustomRetrieveSpecs")
PopupSelectPosition(4, @XPos(ThisElement) + 60, @YPos(ThisElement) + 20)
vName = @PopupMenu(vSpecs, "Choose Spec to Load")
If vName <> "" Then
{
vSuccess = @SelectTreeItem("Search Menu!Clear Form (F3)")
vRetValues = @GlobalValue(vName)
GetSetRetrieve("SET", vRetValues)
ForceRedraw()
}
** PROGRAMMING SECTION: [Save] [On Element Entry] **
Var vName as String
Var vRetValues as String
Var vSave as Int
Var vSpecs as String
Var vAddToList as Int
vName = @PromptForUserInput("Please Enter a Name for the Custom Spec", "")
vSave = 1
vAddToList = 1
If vName <> "" Then
{
If @Len(@GlobalValue(vName)) > 0 Then
{
vSave = 0
If @ASkUser("Warning", "A Custom Retrieve spec with the name of " + vName + " already exists!", "Do you want to Overwrite it") Then
{
vSave = 1
vAddToList = 0
}
}
If vSave = 1 Then
{
GetSetRetrieve("GET", vRetValues)
GlobalValue(vName, vRetValues)
If vAddToList = 1 Then
{
vSpecs = @GlobalValue("CustomRetrieveSpecs")
vSpecs = @AppendStringArray(vSpecs, vName)
GlobalValue("CustomRetrieveSpecs", vSpecs)
}
}
}
It may be a little rough around the edges as I just wrote it this morning but it should give you an idea of how it could be done. And the only changes anyone should have to make is to change the last line in global code that reads
gsButtonList = "Load;Save"
to be the names of the buttons that they only want visible at the retrieve spec.
I have all this in a sample app if anyone would like to see it. Just send an E-mail to support@lantica.com and ask for SaveCustomRetrieves.db
If you really wanted to you could also add a button to delete a custom spec, or even set it as the default spec.
-Ray
-Edit-
Had to add a ForceRedraw() to the Load portion of the code to cause the form to redraw.