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

Re: [MacPerl] GUSI and mime converting



If you'd like I could send you the entire code (the subroutines add 50 or so
lines that print out mime types (like TEXT/ttxt=..., TEXT/McPL=... ...)
"mime_print()", "mime_list()", and "mime_list_all()" are all subroutines.

The program will run fine (ie, compiles and runs) problem is it doesn't do what
it should. As far as I can tell this is only that I don't understand the use of
GUSI and thus can't manipulate it correctly. When the program is run as a
droplet (dropping files on it rather than running it) it works fine.

The "die" statements are so you can quit out of the program (if you wanted to
just see the mime of a file rather than change it, changed your mind, made a
mistake...). The only more descriptive they'd become would be if they said
"user halted program".

It's not a matter of grammer (strict and -w pass fine), it's a matter of
context. What I'm trying to do in the "unless (@ARGV)" loop is...
...if program is executed, not as a droplet, select a file.
...continue with the rest of the program as if said file were droped on the
program.

Below is the complete code (60 charecters wide).
--nick




#!perl -w

############################################################
# MIME converter droplet, ver 2.2.2 (beta)                 #
#      by Nick Thornton                                    #
#                                                          #
#                                                          #
# ver 2.2.2 -- 'list' & 'list all' commands (no non-drop)  #
# ver 2.2.1 -- Multifile dropping (no non-drop support)    #
# ver 2.2 -- added non-droplet support                     #
# ver 2.1 (2.1.1) -- optimized code                        #
# ver 2.0 -- Added mime_print()                            #
# ver 1.0 -- original version                              #
#######################################################(14)#

require "GUSI.ph";

unless (@ARGV) {
     $prompt = "Select a file...";
     $default = "Wild Colonials:Desktop Folder:";
     $file = MacPerl::Choose(&GUSI::AF_FILE, 0, $prompt,
          &GUSI::pack_sa_constr_file(@types),
          ($default ? &GUSI::CHOOSE_DEFAULT : 0),$default);
}

foreach $file (@ARGV) {
     print "\n","###############\n", $file, "\n";
     print join "/", reverse MacPerl::GetFileInfo(@ARGV);
     print "\n###############\n";

     BEGINNING:
     $type = MacPerl::Ask('Type?');
     if ($type eq 'die') {die "\n####################\n"}
     if ($type eq 'list') {
          mime_list();
          goto BEGINNING;
     }
     if ($type eq 'list all') {
          mime_list_all();
          goto BEGINNING;
     }
     mime_print();

     $creator = MacPerl::Ask($type.'/Creator?');
     MacPerl::SetFileInfo($creator, $type, $file);
     print "\n####################\n";
}

#######################################################(49)#

sub mime_print {
     print "\n";
     if ($type eq 'TEXT') {
          print "TEXT/ttxt --> SimpleText\n";
          print "TEXT/MOSS --> Netscape\n";
          print "TEXT/JyWs --> PageSpinner\n";
          print "TEXT/McPL --> MacPerl text\n";
          print "TEXT/MSWD --> MS Word text\n";
     } elsif ($type eq 'ttro') {
          print "ttro/ttxt --> SimpleText read only\n";
     } elsif ($type eq 'W6BN') {
          print "W6BN/MSWD --> MS Word 6.0/95\n";
     } elsif ($type eq 'GIFf') {
          print "GIFf/ogle --> PictureViewer GIF\n";
          print "GIFf/GKON --> GraphicConverter GIF\n";
     } elsif ($type eq 'JPEG') {
          print "JPEG/ogle --> PictureViewer GIF\n";
          print "JPEG/GKON --> GraphicConverter GIF\n";
     } elsif ($type eq 'MPEG') {
          print "MPEG/ICQA --> ICQ mp3\n";
          print "MPEG/mAmp --> macAMP mp3\n";
          print "MPEG/SCPL --> 'MPEG file'\n";
          print "MPEG/???? --> internet mp3\n";
     } elsif ($type eq 'SITD') {
          print "SITD/SITx --> StuffIt archive\n";
     } elsif ($type eq 'SIT5') {
          print "SIT5/SITx --> StuffIt 5 archive\n";
     }
}

sub mime_list {
     print "\n";
     print "#####################################\n";
     print "#  TEXT     ttro     W6BN     GIFf  #\n";
     print "#  JPEG     MPEG     SITD     SIT5  #\n";
     print "#####################################\n";
}

sub mime_list_all {
     print "\n";
     print "############################################\n";
     print "#  TEXT/ttxt --> SimpleText                #\n";
     print "#  TEXT/MOSS --> Netscape                  #\n";
     print "#  TEXT/JyWs --> PageSpinner               #\n";
     print "#  TEXT/McPL --> MacPerl text              #\n";
     print "#  TEXT/MSWD --> MS Word text              #\n";
     print "#                                          #\n";
     print "#  ttro/ttxt --> SimpleText read only      #\n";
     print "#                                          #\n";
     print "#  W6BN/MSWD --> MS Word 6.0/95            #\n";
     print "#                                          #\n";
     print "#  GIFf/ogle --> PictureViewer GIF         #\n";
     print "#  GIFf/GKON --> GraphicConverter GIF      #\n";
     print "#                                          #\n";
     print "#  JPEG/ogle --> PictureViewer GIF         #\n";
     print "#  JPEG/GKON --> GraphicConverter GIF      #\n";
     print "#                                          #\n";
     print "#  MPEG/ICQA --> ICQ mp3                   #\n";
     print "#  MPEG/mAmp --> macAMP mp3                #\n";
     print "#  MPEG/SCPL --> 'MPEG file'               #\n";
     print "#  MPEG/???? --> internet mp3              #\n";
     print "#                                          #\n";
     print "#  SITD/SITx --> StuffIt archive           #\n";
     print "#                                          #\n";
     print "#  SIT5/SITx --> StuffIt 5 archive         #\n";
     print "############################################\n";
}

########## EOF #######################################(119)#

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org