#Constant SCREEN_WIDTH = 640
#Constant SCREEN_HEIGHT = 480
#Constant YEP = 1 `aka "TRUE"
#Constant NAH = 0 `aka "FALSE"
#Constant EXIT_DELAY = 10`in seconds
SetVirtualResolution(SCREEN_WIDTH, SCREEN_HEIGHT)
UseNewDefaultFonts(YEP)
Local strFileToExtract As String = ""
Local strPassword As String = ""
Select GetDeviceBaseName()
`only windows and mac can choose a file from the device's file system.
Case "windows", "mac"
`prompt the user to select a zip file.
Print("Choose a ZIP file to extract...")
Sync()
strFileToExtract = ChooseRawFile("*.zip")
`make sure a legit file was chosen.
If GetFileExists(strFileToExtract)
`Get the password for the zip file, if any.
StartTextInput()
Repeat
Print("Enter Zip file's password. Press [Enter] when done.")
Print("If no password, press [Esc] or leave blank.")
Print("(Extracted files will be empty if password is incorrect.)")
Sync()
Until GetTextInputCompleted()
If GetTextInputCancelled() = NAH Then strPassword = GetTextInput()
`start asynchronous extraction of zip file
ExtractZipASync(strFileToExtract, "", strPassword)
Repeat
Print("Extraction " + Str(GetZipExtractProgress(), 1) + "% complete...")
Sync()
Until GetZipExtractComplete()
ShowMessageAndExit("Files extracted to: " + GetWritePath() + "media")
Else
ShowMessageAndExit("No file selected or file could not be found.")
EndIf
EndCase
`All other devices will have to wait until future versions of AGK, I guess.
`also, ExtractZipASync() doesn't work on some of these anyway.
`Use ExtractZip() instead and let the user guess at the progress.
Case "html5", "ios", "linux", "android"
ShowMessageAndExit("This device is not compatible with the ChooseRawFile() command.")
EndCase
EndSelect
Function ShowMessageAndExit(p_strMessage As String)
ResetTimer()
Repeat
Print(p_strMessage)
Print("Exiting automatically in " + Str(EXIT_DELAY - Timer(), 1) + " seconds.")
Sync()
Until Timer() > EXIT_DELAY Or GetPointerPressed()
End
EndFunction
Help make AGK better by submitting an example for this command! (All examples are subject to approval)