How do I use the ExtractAttachedFile command?

Started by pguild, August 04, 2023, 02:17:58 PM

Previous topic - Next topic

pguild

I am wondering how to properly use the ExtractAttachedFile command.
I have compiled my Winbatch script to an .exe with the skip extraction option in settings.
Thanks to Winbatch Techsupport I found that this code works great:

if ! fileexist("prompts.txt")
   pause("Support files need to be extracted","Press OK to continue.")

   ;Extract other files if they don't already exist
   rc = 0
   files[0] = "prompts.txt"
   files[1] = "BigArticle.txt"
   files[2] = "Determined.txt"
   files[3] = "Editor.txt"
   files[4] = "Encouraging.txt"
   files[5] = "Fitness-enhancing.txt"
   files[6] = "Inspirational.txt"
   files[7] = "MakePrompt.txt"
   files[8] = "Oneliners.txt"
   files[9] = "people.txt"

   foreach file in files
      if ! FileExist(file)
         rc = ExtractAttachedFile(file, file)
      endif
   next

   if rc
      pause("Yes","The support files have been extracted!")
   else
      pause("Oops","Support files not extracted.")
   endif
endif

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

td

A generalized example:

Code (winbatch) Select
; Extenders.
list =  ExtractAttachedFile("", 1)
files = Arrayize(list, @tab)
foreach file in files
   ; Could version check instead of
   ; just checking for existence here.
   if FileExist(file) then continue
   ExtractAttachedFile(file, file)
next

; Other files.
list =  ExtractAttachedFile("", 2)
files = Arrayize(list, @tab)
foreach file in files
   if FileExist(file) then continue
   ExtractAttachedFile(file, file)
next

exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade