[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ProDos file type question



Somewhere earlier in this thread, I think someone was trying to find out
how to change ProDOS file types on a Mac. Recently I made an AppleScript
applet called ProDOSifier that gives files the proper file types for
transfer to ProDOS disks. Do you want me to post it?

For the file type, you can enter a decimal value, a hexadecimal value
(preceded with a $), or a three letter mneumonic like SYS or TXT.

For the aux type, you can enter a decimal value or a hexadecimal value
preceded by a $. For SYS files, this is usually 0. For BAS files, this is
usually 2049 or $0801.

If you are entering a hexadecimal value for either the file type or aux
type, be sure to include all four digits of the hex word. For example, use
$0801 instead of $801 and $0300 instead of $300.

Mind the length of the script and the line breaks made by my newsreader.

on run
   try
      set FileToChange to choose file with prompt "File to ProDOSify?"
   on error
      quit of me
   end try
   set filetypetable to ""
   set filetypetable to (filetypetable &
"UNK~BAD~PCD~PTX~TXT~PDA~BIN~FNT~FOT~BA3~DA3~WPF~SOS~***~***~DIR~RPD~RPI~AFD~AFM~AFR~SCL~PFS~***~***~ADB~AWP~ASP~***~***~***~***~")
   set filetypetable to (filetypetable &
"TDM~IPS~UPV~***~***~***~***~***~***~3SD~8SC~8OB~8IC~8LD~P8C~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"***~OCR~FTD~***~***~***~***~***~***~***~***~***~***~***~***~***~GWP~GSS~GDB~DRW~GDP~HMD~EDU~STN~HLP~COM~CFG~ANM~MUM~ENT~DVU~***~")
   set filetypetable to (filetypetable &
"PRE~***~***~***~***~***~***~***~***~***~***~BIO~***~DRV~PRE~HDV~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"GSF~GDA~GAP~GDF~GFF~GPD~GIN~GAD~***~***~***~GCD~GID~GFD~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"WP_~***~***~***~***~***~***~***~***~***~***~GSB~TDF~BDF~***~***~SRC~OBJ~LIB~S16~RTL~EXE~PIF~TIF~NDA~CDA~TOL~DVR~LDF~FST~***~DOC~")
   set filetypetable to (filetypetable &
"PNT~PIC~ANI~PAL~***~OOG~SCR~CDV~FON~FND~ICN~***~***~***~***~***~***~***~***~***~***~MUS~INS~MDI~SND~***~***~DBM~***~***~***~***~")
   set filetypetable to (filetypetable &
"LBR~***~ATK~***~***~***~***~***~***~***~***~***~***~***~R16~PAS~CMD~OVL~***~***~***~BAT~***~***~PRG~P16~INT~IVR~BAS~VAR~REL~SYS~")
   set newtype to "p"
   set pdosftype to text returned of (display dialog "ProDOS File Type?"
default answer "SYS" buttons {"OK"} default button 1)
   set pdosatype to text returned of (display dialog "ProDOS Aux. Type?"
default answer "0" buttons {"OK"} default button 1)
   if (offset of "$" in pdosatype) � 0 then -- entry is in hexadecimal
      set valuePlace1 to (offset of (character 2 of pdosatype) in
"123456789ABCDEF")
      set valuePlace2 to (offset of (character 3 of pdosatype) in
"123456789ABCDEF")
      set valuePlace3 to (offset of (character 4 of pdosatype) in
"123456789ABCDEF")
      set valuePlace4 to (offset of (character 5 of pdosatype) in
"123456789ABCDEF")
      set pdosatype to ((valuePlace1 * 4096) + (valuePlace2 * 256) +
(valuePlace3 * 16) + valuePlace4) as string
   end if
   if (offset of "$" in pdosftype) � 0 then -- entry is in hexadecimal
      set valuePlace1 to (offset of (character 2 of pdosftype) in
"123456789ABCDEF")
      set valuePlace2 to (offset of (character 3 of pdosftype) in
"123456789ABCDEF")
      set pdosftype to ((valuePlace1 * 16) + valuePlace2) as string
   end if
   if (length of pdosftype) = 3 then
      if (((ASCII number (character 1 of pdosftype)) < 48) or ((ASCII
number (character 1 of pdosftype)) > 57) or ((ASCII number (character 2 of
pdosftype)) < 48) or ((ASCII number (character 2 of pdosftype)) > 57) or
((ASCII number (character 3 of pdosftype)) < 48) or ((ASCII number
(character 3 of pdosftype)) > 57)) then
         -- entry is a three-letter file extension
         set ofst to (offset of pdosftype in filetypetable)
         if ofst = 0 then
            display dialog "Not a valid file type." buttons {"Quit"}
default button 1
            quit of me
         end if
         set pdosftype to ((ofst - 1) / 4) as string
      end if
   end if
   set pdosatypehigh to (round (pdosatype / 256) rounding down) as string
   set pdosatypelow to (pdosatype - (pdosatypehigh * 256)) as string
   set newtype to (newtype & (ASCII character (pdosftype)) & (ASCII
character (pdosatypehigh)) & (ASCII character (pdosatypelow)))
   set newcreator to "pdos"
   tell application "Finder"
      set file type of FileToChange to newtype
      set creator type of FileToChange to newcreator
   end tell
end run

on open x
   set k to button returned of (display dialog "Would you like to
ProDOSify the files all at once or individually?" buttons {"All at Once",
"Individually"} default button "All at Once")
   if k = "All at Once" then pdosifyAll(x)
   if k = "Individually" then pdosifyIndiv(x)
end open

on pdosifyAll(x)
   set filetypetable to ""
   set filetypetable to (filetypetable &
"UNK~BAD~PCD~PTX~TXT~PDA~BIN~FNT~FOT~BA3~DA3~WPF~SOS~***~***~DIR~RPD~RPI~AFD~AFM~AFR~SCL~PFS~***~***~ADB~AWP~ASP~***~***~***~***~")
   set filetypetable to (filetypetable &
"TDM~IPS~UPV~***~***~***~***~***~***~3SD~8SC~8OB~8IC~8LD~P8C~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"***~OCR~FTD~***~***~***~***~***~***~***~***~***~***~***~***~***~GWP~GSS~GDB~DRW~GDP~HMD~EDU~STN~HLP~COM~CFG~ANM~MUM~ENT~DVU~***~")
   set filetypetable to (filetypetable &
"PRE~***~***~***~***~***~***~***~***~***~***~BIO~***~DRV~PRE~HDV~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"GSF~GDA~GAP~GDF~GFF~GPD~GIN~GAD~***~***~***~GCD~GID~GFD~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
   set filetypetable to (filetypetable &
"WP_~***~***~***~***~***~***~***~***~***~***~GSB~TDF~BDF~***~***~SRC~OBJ~LIB~S16~RTL~EXE~PIF~TIF~NDA~CDA~TOL~DVR~LDF~FST~***~DOC~")
   set filetypetable to (filetypetable &
"PNT~PIC~ANI~PAL~***~OOG~SCR~CDV~FON~FND~ICN~***~***~***~***~***~***~***~***~***~***~MUS~INS~MDI~SND~***~***~DBM~***~***~***~***~")
   set filetypetable to (filetypetable &
"LBR~***~ATK~***~***~***~***~***~***~***~***~***~***~***~R16~PAS~CMD~OVL~***~***~***~BAT~***~***~PRG~P16~INT~IVR~BAS~VAR~REL~SYS~")
   set newtype to "p"
   set pdosftype to text returned of (display dialog "ProDOS File Type?"
default answer "SYS" buttons {"OK"} default button 1)
   set pdosatype to text returned of (display dialog "ProDOS Aux. Type?"
default answer "0" buttons {"OK"} default button 1)
   if (offset of "$" in pdosatype) � 0 then -- entry is in hexadecimal
      set valuePlace1 to (offset of (character 2 of pdosatype) in
"123456789ABCDEF")
      set valuePlace2 to (offset of (character 3 of pdosatype) in
"123456789ABCDEF")
      set valuePlace3 to (offset of (character 4 of pdosatype) in
"123456789ABCDEF")
      set valuePlace4 to (offset of (character 5 of pdosatype) in
"123456789ABCDEF")
      set pdosatype to ((valuePlace1 * 4096) + (valuePlace2 * 256) +
(valuePlace3 * 16) + valuePlace4) as string
   end if
   if (offset of "$" in pdosftype) � 0 then -- entry is in hexadecimal
      set valuePlace1 to (offset of (character 2 of pdosftype) in
"123456789ABCDEF")
      set valuePlace2 to (offset of (character 3 of pdosftype) in
"123456789ABCDEF")
      set pdosftype to ((valuePlace1 * 16) + valuePlace2) as string
   end if
   if (length of pdosftype) = 3 then
      if (((ASCII number (character 1 of pdosftype)) < 48) or ((ASCII
number (character 1 of pdosftype)) > 57) or ((ASCII number (character 2 of
pdosftype)) < 48) or ((ASCII number (character 2 of pdosftype)) > 57) or
((ASCII number (character 3 of pdosftype)) < 48) or ((ASCII number
(character 3 of pdosftype)) > 57)) then
         -- entry is a three-letter file extension
         set ofst to (offset of pdosftype in filetypetable)
         if ofst = 0 then
            display dialog "Not a valid file type." buttons {"Quit"}
default button 1
            quit of me
         end if
         set pdosftype to ((ofst - 1) / 4) as string
      end if
   end if
   set pdosatypehigh to (round (pdosatype / 256) rounding down) as string
   set pdosatypelow to (pdosatype - (pdosatypehigh * 256)) as string
   set newtype to (newtype & (ASCII character (pdosftype)) & (ASCII
character (pdosatypehigh)) & (ASCII character (pdosatypelow)))
   set newcreator to "pdos"
   repeat with y in x
      tell application "Finder"
         set file type of y to newtype
         set creator type of y to newcreator
      end tell
   end repeat
end pdosifyAll

on pdosifyIndiv(x)
   repeat with y in x
      set FileToChange to y
      set filetypetable to ""
      set filetypetable to (filetypetable &
"UNK~BAD~PCD~PTX~TXT~PDA~BIN~FNT~FOT~BA3~DA3~WPF~SOS~***~***~DIR~RPD~RPI~AFD~AFM~AFR~SCL~PFS~***~***~ADB~AWP~ASP~***~***~***~***~")
      set filetypetable to (filetypetable &
"TDM~IPS~UPV~***~***~***~***~***~***~3SD~8SC~8OB~8IC~8LD~P8C~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
      set filetypetable to (filetypetable &
"***~OCR~FTD~***~***~***~***~***~***~***~***~***~***~***~***~***~GWP~GSS~GDB~DRW~GDP~HMD~EDU~STN~HLP~COM~CFG~ANM~MUM~ENT~DVU~***~")
      set filetypetable to (filetypetable &
"PRE~***~***~***~***~***~***~***~***~***~***~BIO~***~DRV~PRE~HDV~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
      set filetypetable to (filetypetable &
"GSF~GDA~GAP~GDF~GFF~GPD~GIN~GAD~***~***~***~GCD~GID~GFD~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~***~")
      set filetypetable to (filetypetable &
"WP_~***~***~***~***~***~***~***~***~***~***~GSB~TDF~BDF~***~***~SRC~OBJ~LIB~S16~RTL~EXE~PIF~TIF~NDA~CDA~TOL~DVR~LDF~FST~***~DOC~")
      set filetypetable to (filetypetable &
"PNT~PIC~ANI~PAL~***~OOG~SCR~CDV~FON~FND~ICN~***~***~***~***~***~***~***~***~***~***~MUS~INS~MDI~SND~***~***~DBM~***~***~***~***~")
      set filetypetable to (filetypetable &
"LBR~***~ATK~***~***~***~***~***~***~***~***~***~***~***~R16~PAS~CMD~OVL~***~***~***~BAT~***~***~PRG~P16~INT~IVR~BAS~VAR~REL~SYS~")
      set newtype to "p"
      set pdosftype to text returned of (display dialog ("ProDOS File Type
of " & (y as string) & "?") default answer "SYS" buttons {"OK"} default
button 1)
      set pdosatype to text returned of (display dialog ("ProDOS Aux. Type
of " & (y as string) & "?") default answer "0" buttons {"OK"} default
button 1)
      if (offset of "$" in pdosatype) � 0 then -- entry is in hexadecimal
         set valuePlace1 to (offset of (character 2 of pdosatype) in
"123456789ABCDEF")
         set valuePlace2 to (offset of (character 3 of pdosatype) in
"123456789ABCDEF")
         set valuePlace3 to (offset of (character 4 of pdosatype) in
"123456789ABCDEF")
         set valuePlace4 to (offset of (character 5 of pdosatype) in
"123456789ABCDEF")
         set pdosatype to ((valuePlace1 * 4096) + (valuePlace2 * 256) +
(valuePlace3 * 16) + valuePlace4) as string
      end if
      if (offset of "$" in pdosftype) � 0 then -- entry is in hexadecimal
         set valuePlace1 to (offset of (character 2 of pdosftype) in
"123456789ABCDEF")
         set valuePlace2 to (offset of (character 3 of pdosftype) in
"123456789ABCDEF")
         set pdosftype to ((valuePlace1 * 16) + valuePlace2) as string
      end if
      if (length of pdosftype) = 3 then
         if (((ASCII number (character 1 of pdosftype)) < 48) or ((ASCII
number (character 1 of pdosftype)) > 57) or ((ASCII number (character 2 of
pdosftype)) < 48) or ((ASCII number (character 2 of pdosftype)) > 57) or
((ASCII number (character 3 of pdosftype)) < 48) or ((ASCII number
(character 3 of pdosftype)) > 57)) then
            -- entry is a three-letter file extension
            set ofst to (offset of pdosftype in filetypetable)
            if ofst = 0 then
               display dialog "Not a valid file type." buttons {"Quit"}
default button 1
               quit of me
            end if
            set pdosftype to ((ofst - 1) / 4) as string
         end if
      end if
      set pdosatypehigh to (round (pdosatype / 256) rounding down) as string
      set pdosatypelow to (pdosatype - (pdosatypehigh * 256)) as string
      set newtype to (newtype & (ASCII character (pdosftype)) & (ASCII
character (pdosatypehigh)) & (ASCII character (pdosatypelow)))
      set newcreator to "pdos"
      tell application "Finder"
         set file type of FileToChange to newtype
         set creator type of FileToChange to newcreator
      end tell
   end repeat
end pdosifyIndiv

-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
jonrelay@napanet.net                        dimension18.cjb.net
An Apple II fanatic since 1998!     S0.5 LIS+++! Suzy+++! M1987
"Remember, if it's not a secure web server, it's an _insecure_
web server!"                                             -- Me

 *_     Syntax Error: an error on a criminal's tax record.
   |    Bad Subscript: a criminal reading a book on a subway.
  ---   Unimplemented Trap: when a bear trap isn't set up 
 |' ,|  properly and thus does not work.
  ---   Overflow: too many ice cubes.      <Can't Restart>

          Don't forget: Tammy Day on February 15th!
Please remove capital letters from my e-mail address to respond.