--BUTTON EXAMPLE SCRIPT: on mouseUp global choice global thePath global theFiles put empty into prompt put empty into parameter put empty into filters put PictureChooser(prompt,parameter,filters) into choice answer choice answer thePath answer theFiles end mouseUp --------------------------------------------------------------- --------------------------------------------------------------- --STACK SCRIPT: on preOpenStack global progFolder set the itemDelimiter to "/" put $0 into progFolder delete the last item of progFolder set the defaultFolder to progFolder end preOpenStack --------------------------------------------------------------- function FileChooser prompt,parameter,filters global progFolder global ProgToShell$ global chooserOutputFile global choice global thePath global theFiles checkINIfilesExist put textEncode(prompt,"UTF-8") into url ("file:_file_chooser_prompt_file.txt") if prompt is empty then put textEncode(empty,"UTF-8") into line 2 of url ("file:_file_chooser.ini") else put textEncode("_file_chooser_prompt_file.txt","UTF-8") into line 2 of url ("file:_file_chooser.ini") end if put textEncode(parameter,"UTF-8") into line 16 of url ("file:_file_chooser.ini") put textEncode(filters,"UTF-8") into url ("file:_file_chooser_filters.ini") put (progFolder & "\_file_chooser.exe") into ProgToShell$ put (progFolder & "\_file_chooser_choice.txt") into chooserOutputFile call callChooser of this stack if parameter = "folder" or parameter = "folder\" then put choice into thePath put empty into thefiles else set the itemDelimiter to "\" put choice into thePath delete the last item of thePath --if thePath = "c:" then put "c:\" into thePath if the last char of thePath = ":" then put thePath & "\" into thePath put the last item of choice into theFiles replace "|" with return in theFiles end if return choice end FileChooser --------------------------------------------------------------- function PictureChooser prompt,parameter,filters global progFolder global ProgToShell$ global chooserOutputFile global choice global thePath global theFiles checkINIfilesExist put textEncode(prompt,"UTF-8") into url ("file:_picture_chooser_prompt_file.txt") if prompt is empty then put textEncode(empty,"UTF-8") into line 2 of url ("file:_picture_chooser.ini") else put textEncode("_picture_chooser_prompt_file.txt","UTF-8") into line 2 of url ("file:_picture_chooser.ini") end if put textEncode(parameter,"UTF-8") into line 16 of url ("file:_picture_chooser.ini") put textEncode(filters,"UTF-8") into url ("file:_picture_chooser_filters.ini") put (progFolder & "\_picture_chooser.exe") into ProgToShell$ put (progFolder & "\_picture_chooser_choice.txt") into chooserOutputFile call callChooser of this stack if parameter = "folder" or parameter = "folder\" then put choice into thePath put empty into thefiles else set the itemDelimiter to "\" put choice into thePath delete the last item of thePath --if thePath = "c:" then put "c:\" into thePath if the last char of thePath = ":" then put thePath & "\" into thePath put the last item of choice into theFiles replace "|" with return in theFiles end if return choice end PictureChooser --------------------------------------------------------------- on checkINIfilesExist global progFolder put "" & return & "" & return & "" & return & "" & return \ & "" & return & "" & return & "" & return & "" & return \ & "" & return & "" & return & "" & return & "" & return \ & "" & return & "" & return & "" & return & "" into iniFileNullData --Ensure the chooser INI files exist: --if (there is a file progFolder & "\_file_chooser.ini") is false then --DOESN'T WORK put url("file:" & progFolder & "\_file_chooser.ini") into test if test is empty then put textEncode(iniFileNullData,"UTF-8") into url ("file:_file_chooser.ini") --put textEncode("_file_chooser_prompt_file.txt","UTF-8") into line 2 of url ("file:_file_chooser.ini") end if --if (there is a file progFolder & "\_picture_chooser.ini") is false then --DOESN'T WORK put url("file:" & progFolder & "\_picture_chooser.ini") into test if test is empty then put textEncode(iniFileNullData,"UTF-8") into url ("file:_picture_chooser.ini") --put textEncode("_picture_chooser_prompt_file.txt","UTF-8") into line 2 of url ("file:_picture_chooser.ini") end if --_file_chooser_prompt_file.txt --_picture_chooser_prompt_file.txt --if (there is a file progFolder & "\_file_chooser_prompt_file.txt") is false then --DOESN'T WORK put url("file:" & progFolder & "\_file_chooser_prompt_file.txt") into test if test is empty then put textEncode(empty,"UTF-8") into url ("file:_file_chooser_prompt_file.txt") end if --if (there is a file progFolder & "\_picture_chooser_prompt_file.txt") is false then --DOESN'T WORK put url("file:" & progFolder & "\_picture_chooser_prompt_file.txt") into test if test is empty then put textEncode(empty,"UTF-8") into url ("file:_picture_chooser_prompt_file.txt") end if end checkINIfilesExist --------------------------------------------------------------- on callChooser global progFolder global ProgToShell$ global chooserOutputFile global choice delete file chooserOutputFile put empty into choice --Ensure HD employment by chooser. --Put "hd" into line 13 of the INI files: put textEncode("hd","UTF-8") into line 13 of url ("file:_file_chooser.ini") put textEncode("hd","UTF-8") into line 13 of url ("file:_picture_chooser.ini") --Prepare and execute shell: set the hideConsoleWindows to true launch ProgToShell$ --Await result repeat forever wait 2 ticks put url ("file:" & chooserOutputFile) into tTextToDecode put textDecode(tTextToDecode,"UTF-8") into choice if choice is not empty then exit repeat end if end repeat end callChooser ---------------------------------------------------------------