Android Question [SOLVED] B4A Wait For with sftp download command promptYesNo how to?

AscySoft

Active Member
Licensed User
EDIT: I've done it myself, see the last of my posts

I create a new project and I want to include resummable subs/wait for. Here is the working code
B4X:
'sftp is a ProcessGlobal sftp object
sftp.Initialize("vers","user", "pass", "server", 21)
sftp.DownloadFile("ftp/version.txt",Starter.rp.GetSafeDirDefaultExternal(""),"vers.txt")
Wait For vers_DownloadCompleted (ServerPath As String, Success As Boolean)
If Success Then
 Log($"file was downloaded in ${Starter.rp.GetSafeDirDefaultExternal("")}/vers.txt"$)
Else
 Log($"Error...${LastException}"$)
End If
sftp.CloseNow
This code is good, but it will crush the app if I will not create another sub with "vers" event name
B4X:
Sub vers_PromptYesNo (Message As String)
    sftp.SetPromptResult(True)'im my case is a secure server location
End Sub
So the silly question is how to integrate all this in only just one sub completly?
 
Last edited:

AscySoft

Active Member
Licensed User
But this means that if I need to initialize another object "event2" I will need to create a second
Sub event2_PromptYesNo (Message As String)...
In this way I will repeat myself (and I'me trying not to) becouse depending on the cmplexity of the project this approach is hard to mentain.
That's why I asked his question, maybe someone else descovered a "secret shortcut" :)
 
Top