I’ve created a method InputDeviceSampleRate which opens a modal window for text input. This works fine on it’s own.
Now I need to call that method after the user selects a file from the open/import dialog box:
After selecting a file, then selecting “Open”, the user will see this:
What needs to happen is that if the user selects cancel in the modal window, then it should back out to the open dialog box, otherwise the user enters a number and selects OK and we proceed as normal.
It’s taken me many hours just to get to the point of opening a valid file and evaluating the data. Nevertheless, the text input from the modal window is a must for my program to work. At the moment I’m struggling to work out where to insert the method call. This is my current code:
[code]// IMPORT Files
Dim dlg As OpenDialog
Dim f As FolderItem
dlg = New OpenDialog
dlg.Title = “Import File”
dlg.Filter = FileTypes1.All //Restrict file types
f = dlg.ShowModal
If f <> Nil Then
ReDim tempArray(-1)
cursorFinalPositionX=0
recordedGramsArrayIndex=0
If f.Exists Then
Dim dataInput As TextInputStream
Try
dataInput = TextInputStream.Open(f)
tempArray() = Split(dataInput.ReadAll,EndOfLine) //(Encodings.ASCII)
dataInput.Close
Catch e As IOException
MsgBox("Error accessing file.")
End Try
End If
EvaluateImportedData
End If
cnvGRAPH.SetFocus // if cancelled[/code]
I think that Try/Catch/End Try, is complicating things. I’m not sure if it’s really needed.
Ok, thanks Emile. My fault for not explaining well enough.
What I was thinking is that when the user selects a file in the open dialog, then clicks the “open” button, a modal window opens asking for input. As per this mockup:
If the user selects cancel then the modal window closes but the open file dialog remains for the user to make another choice. In real life it’s probably not necessary, but more of an aesthetic.
I’ve since realised that it’s not going to happen that way. After the user selects open, the open file dialog closes (as it well should) and then the modal opens, now showing the main window underneath:
It’s not the way I’d like it to look, but it will work fine.