Here is a quick one I did on another platform, however, do not know FTV basic but most of the commands should be there, the things that you may have to change are getting & setting the variables as on this the GetVariableValue( ) function is probably only for this platform I have no idea how you reference variable tags in FTV, the same goes for standard windows controls like MsgBox & Combobox, you may have to roll your own.
I wrote this in about 2 hours so the error handling may not be tested fully.
' Saving the recipe
Sub Main()
Dim FileNum,i As Integer
Dim j As Variant
Dim FileName, TempStr1 As String
On Error GoTo ErrorHndl
FileName = CurDir 'Here I'm just getting the current directory of the project
FileName = FileName + "\Recipe" + GetVariableValue("Edit_Recipe_Name") ' then adding the folder & edit recipe name
If GetVariableValue("Edit_Recipe_Name") = "" Then 'If the edit recipe name is null then pop up error
If MsgBox ("Recipe has no name", vbMsgBoxSetForeground,"Error") = vbOK Then
Exit Sub 'then exit because we cannot save a recipe without a name
End If
End If
FileNum = FreeFile
Open FileName For Binary Lock Read Write As #FileNum
For i = 1 To 10
TempStr1 = "Edit_Recipe_" + Trim (Str(i)) 'my tags are referenced by strings so need to build the strings
j = GetVariableValue(TempStr1) 'Move the values into the file from the Edit Recipe Tags
Put #FileNum,,j
Next
Close #FileNum
Exit Sub
ErrorHndl:
MsgBox (Str(Error), vbExclamation,"Error") 'On an error show error
End Sub
' This is the Recipe load code, it selects a recipe from those stored in the directory
Sub Main()
Dim DirStr,FileStr, RecipeName As String
Dim ListStr(300) As String ' Just set a limit of 300 for number of recipes probably never have that many
Dim FileNumber, Inc, x, i As Integer
Dim j As Variant ' this is a variant which allows it to be used for many types of values i.e. float or integer
On Error GoTo Errhndl 'On error go to error handler
FileNumber = FreeFile 'Return the next free file number note: the file type is binary
DirStr = CurDir() + "\Recipe\*." 'Create the directory string
Inc = 0
FileStr = Dir(DirStr) 'load all the files in the recipe directory
ListStr(Inc) = FileStr
Inc = Inc + 1
While FileStr <> ""
ListStr(Inc) = Dir()
FileStr = ListStr(Inc)
Inc = Inc + 1
Wend
Begin Dialog UserDialog 190,180 'create a user dialog with a combo box
Text 10,10,190,25,"Please Select Recipe"
ComboBox 10,50,180,100,ListStr(),.combo 'populate the combo box lists with the recipes
OKButton 60,155,60,20
End Dialog
Dim dlg As UserDialog
dlg.combo = "none"
Dialog dlg ' show dialog (wait for ok)
RecipeName = dlg.combo 'return the recipe selected
FileStr = CurDir 'Get the current directory, here I'm using the application directory
FileStr = FileStr + "\Recipe" + RecipeName
FileNumber = FreeFile
Open FileStr For Binary Lock Read Write As #FileNumber
SetVariableValue("Recipe_Name",RecipeName) 'Update the current recipe name
For i = 1 To 10 'Load the values into the variables
TempStr1 = "Recipe_" + Trim (Str(i))
Get #FileNumber,,j
SetVariableValue(TempStr1,j) 'update the recipe tags
Next
Close #FileNumber
SetVariableValue("Recipe_Name",RecipeName) 'Update the current recipe name
Exit Sub
Errhndl:
MsgBox (Str(Error), vbExclamation,"Error") 'On an error show error
Exit Sub
End Sub
You could add deleting recipes and I would suggest put the recipe edit & recipe load on separate screens, I did this just as a demo