[comp.sys.amiga] Has anyone gotten

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (01/30/89)

In <35254@bbn.COM>, cosell@bbn.com (Bernie Cosell) writes:
>The subject mostly says it all: I've tried using IconType (FTP'ed out of the
>archives from some Fish disk, if I recall) and had no success.  IconType is
>supposed to let you change the type of an icon.  I need something like that
>every now and then (mostly to change 'tool' to 'project' icons when I need/want
>to move the underlying program somehwere else).  When I try
>   icontype myicon.info project
>it acts like it just completed OK (no diagnostics or anything) but:
>  a) the type of the icon DIDNT really get changed, and
>  b) my CLI won't go away (endcli doesn't).
>
>Has anyone had any luck with IconType?  Does anyone have some OTHER utility
>(presumably better-known to work) that will do a similar job?  Thanks

Well, it beats the heck out of me. I wrote it a long time ago, and C is not my
first (or favourite) language. I struggled a lot with it, even just trying to
find out the offset of the 'type' value was a chore. I just now tried playing
with it, and it does seem to work for me in that it changes the type to what I
ask for, but does indeed prevent the CLI from closing. This is not something I
would notice, since I usually don't have a WB up, and never close the two CLI's
I run all the time.

Did you get the Readme for it? It does state that if a window containing the
icon is open, that it needs to be closed, then opened in order to have the type
change 'take' when looked at with the INFO menu selection.

Now here's the interesting part. My current include files show different
definitions of do_Type. My assembler includes show this field to be a UWORD,
and my C includes show it to be a UBYTE. Looking at the Type value in an actual
icon file would seem to indicate that it is a UBYTE, which is what I treated it
as in the program.

I have no idea at all why the CLI won't close, since there is nothing fancy
going on in the code. Here's the code; perhaps someone can spot the problem.

------------------------------------
/* IconType - a program to change the type of icon. Useful for changing
 *            an icon's type after editing with IconEd.
 *
 * Icon types are Disk, Drawer, Tool, Project, Garbage, and Device
 *
 * Syntax: icontype <filename> <type>
 *
 * Example: icontype test.info project
 *          (changes the icon "test.info" to a project icon)
 *
 * by: Larry Phillips, CIS 76703,4322
 */

#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/libraries.h"
#include "exec/ports.h"
#include "exec/interrupts.h"
#include "exec/io.h"
#include "exec/memory.h"
#include "libraries/dos.h"
#include "libraries/dosextens.h"

extern struct FileHandle *Open();

main (argc,argv)
int argc;
char *argv[];

{
  struct FileHandle *file;
  unsigned char buf;
  static char *type[7] = { "","disk","drawer","tool","project","garbage","device" };
  if ((argc < 3)||(argc > 3))
   {
    puts("Usage: IconType <filename> <type>\nTypes are disk, drawer, tool, project, garbage, device.");
   }
  else
   {
    if ((file = Open(argv[1],MODE_OLDFILE))==0)
      {
        puts ("Unable to open icon file.");
        Exit();
      }

    Read (file,&buf,1L);

    if (buf == 0xE3)
      {
        Read (file,&buf,1L);
        if (buf == 0x10)
          {
            Seek (file, 48L,(long) OFFSET_BEGINNING);
            tolower (argv[2]);
            for (buf = 1;buf < 7;buf++)
               if (strcmp(argv[2],type[buf])==0)
                 {
                   Write (file,&buf,1L);
                   break;
                 }
            if (buf == 7) puts ("Invalid icon type.");
            printf("%d ",buf);
          }
        else puts ("Not an icon file.");
      }
    else puts ("Not an icon file.");

    Close (file);
    Exit  ();
  }
}
------------------------------------

--
Frisbeetarianism: The belief that when you die, your soul goes up on
                  the roof and gets stuck.
+----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                |
| \X/    lphillips@lpami.wimsey.bc.ca or uunet!van-bc!lpami!lphillips  |
|        COMPUSERVE: 76703,4322                                        |
+----------------------------------------------------------------------+

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (01/30/89)

In <2190@van-bc.UUCP>, I write:
>>Has anyone had any luck with IconType?  Does anyone have some OTHER utility
>>(presumably better-known to work) that will do a similar job?  Thanks

>I have no idea at all why the CLI won't close, since there is nothing fancy
>going on in the code. Here's the code; perhaps someone can spot the problem.

Well, after conferring with a few friends, it seems that I used the Amigados
Exit() function instead of the Manx exit() function. Replacing it allows the
CLI to close after the program is run. I left only the error exit() in place,
and allow the program to 'drop out'. I also eliminated the printf(), since it
was in there for debugging purposes only. New size is 4432 bytes when compiled.
Here's the corrected code:

---------------------------------

/* IconType - a program to change the type of icon. Useful for changing
 *            an icon's type after editing with IconEd.
 *
 * Icon types are Disk, Drawer, Tool, Project, Garbage, and Device
 *
 * Syntax: icontype <filename> <type>
 *
 * Example: icontype test.info project
 *          (changes the icon "test.info" to a project icon)
 *
 * by: Larry Phillips, CIS 76703,4322
 */

#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/libraries.h"
#include "exec/ports.h"
#include "exec/interrupts.h"
#include "exec/io.h"
#include "exec/memory.h"
#include "libraries/dos.h"
#include "libraries/dosextens.h"

extern struct FileHandle *Open();

main (argc,argv)
int argc;
char *argv[];

{
  struct FileHandle *file;
  unsigned char buf;
  static char *type[7] = { "","disk","drawer","tool","project","garbage","device" };
  if ((argc < 3)||(argc > 3))
   {
    puts("Usage: IconType <filename> <type>\nTypes are disk, drawer, tool, project, garbage, device.");
   }
  else
   {
    if ((file = Open(argv[1],MODE_OLDFILE))==0)
      {
        puts ("Unable to open icon file.");
        exit(205);
      }

    Read (file,&buf,1L);

    if (buf == 0xE3)
      {
        Read (file,&buf,1L);
        if (buf == 0x10)
          {
            Seek (file, 48L,(long) OFFSET_BEGINNING);
            tolower (argv[2]);
            for (buf = 1;buf < 7;buf++)
               if (strcmp(argv[2],type[buf])==0)
                 {
                   Write (file,&buf,1L);
                   break;
                 }
            if (buf == 7) puts ("Invalid icon type.");
          }
        else puts ("Not an icon file.");
      }
    else puts ("Not an icon file.");

    Close (file);
  }
}


--
Frisbeetarianism: The belief that when you die, your soul goes up on
                  the roof and gets stuck.
+----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                |
| \X/    lphillips@lpami.wimsey.bc.ca or uunet!van-bc!lpami!lphillips  |
|        COMPUSERVE: 76703,4322                                        |
+----------------------------------------------------------------------+

jms@antares.UUCP (Joe Smith) (02/05/89)

In article <2194@van-bc.UUCP> lphillips@lpami.wimsey.bc.ca (Larry Phillips) writes:
>>>Has anyone had any luck with IconType?  Does anyone have some OTHER utility
>>>(presumably better-known to work) that will do a similar job?  Thanks
>Here's the corrected code:
	[IconType.c deleted]

Well I just tried IconType, and it produced the most spectacular
crash I've ever seen.  Just after compiling it, this is what I did:

	1>CD SYS2:
	1>copy system/IconEd.info TEST.info
	1>makedir TEST
	1>IconType TEST drawer
	1>loadwb

The TEST icon showed up in the SYS2: window.  I single-clicked on it and
chose INFO from the menu and verified that the icon was of type Drawer.
Then I double-clicked the icon.  Boy, you should have seen the fireworks!

Both disk drives started grumbling at about 7 Hz.  The SEND and RECV lights
on the modem flickered between full and half brightness in sync with the
disks.  The screen made pretty black, white, and green patterns that looked
like "random" bits from executable code.  Then it froze, with the screen
white and the light on DF0 on but the disk was not spinning.

Giving my Amiga the three-fingered salute, I tried to reboot from my usual
Workbench disk.  It died in the middle of the startup-sequence with:
	Internal clock not functioning
	Setclock failed returncode 20
Luckily, a 30-second power down fixed this problem.  Otherwise I would have
had to disassemble my A2000 to temporarily disconnect the battery to reset
the clock.

It looks like I will have to use SIT from Fish Disk #137 instead of IconType.
The Set-Icon-Type program by Stephen Vermeulen knows that you can't change
a Tool icon to a Drawer icon by simply rewriting one byte.  SIT reads an
existing Drawer/Disk/Trashcan icon to get the proper info for setting up
the do_DrawerInfo field.

So, Larry, did you actually test your program?

> +----------------------------------------------------------------------+ 
> |   //   Larry Phillips                                                |
> | \X/    lphillips@lpami.wimsey.bc.ca or uunet!van-bc!lpami!lphillips  |
> |        COMPUSERVE: 76703,4322                                        |
> +----------------------------------------------------------------------+
-- 
Joe Smith (408)922-6220 | jms@antares.Tymnet.COM[131.146.3.1] or jms@opus
McDonnell Douglas FSCO  | UUCP: {ames,pyramid}!oliveb!tymix!antares!jms
PO Box 49019, MS-D21    | PDP-10: JMS@F74.Tymnet   CA license plate: "POPJ P,"
San Jose, CA 95161-9019 | narrator.device: "I didn't say that, my Amiga did!"

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (02/07/89)

In <381@antares.UUCP>, jms@antares.UUCP (Joe Smith) writes:
>In article <2194@van-bc.UUCP> lphillips@lpami.wimsey.bc.ca (Larry Phillips) writes:
>>>>Has anyone had any luck with IconType?  Does anyone have some OTHER utility
>>>>(presumably better-known to work) that will do a similar job?  Thanks
>>Here's the corrected code:
>	[IconType.c deleted]
>
>Well I just tried IconType, and it produced the most spectacular
>crash I've ever seen.  Just after compiling it, this is what I did:
>
>	1>CD SYS2:
>	1>copy system/IconEd.info TEST.info
>	1>makedir TEST
>	1>IconType TEST drawer
>	1>loadwb

Well, I hope it at least complained about the filename. :-)

>The TEST icon showed up in the SYS2: window.  I single-clicked on it and
>chose INFO from the menu and verified that the icon was of type Drawer.
>Then I double-clicked the icon.  Boy, you should have seen the fireworks!

Ahh... OK. When I made the changes, I did not check for double-clicking. The
original program worked for me, and the changes I made were to allow the CLI to
close. I do not currently use WB, and IconType passed all the usage I gave it
when I used to use it.

>Both disk drives started grumbling at about 7 Hz.  The SEND and RECV lights
>on the modem flickered between full and half brightness in sync with the
>disks.  The screen made pretty black, white, and green patterns that looked
>like "random" bits from executable code.  Then it froze, with the screen
>white and the light on DF0 on but the disk was not spinning.
>
>Giving my Amiga the three-fingered salute, I tried to reboot from my usual
>Workbench disk.  It died in the middle of the startup-sequence with:
>	Internal clock not functioning
>	Setclock failed returncode 20
>Luckily, a 30-second power down fixed this problem.  Otherwise I would have
>had to disassemble my A2000 to temporarily disconnect the battery to reset
>the clock.

You really should have Glenn Nielsen's 'Clockstart' program.

>It looks like I will have to use SIT from Fish Disk #137 instead of IconType.
>The Set-Icon-Type program by Stephen Vermeulen knows that you can't change
>a Tool icon to a Drawer icon by simply rewriting one byte.  SIT reads an
>existing Drawer/Disk/Trashcan icon to get the proper info for setting up
>the do_DrawerInfo field.

Please do. I am not being sarcastic. I wrote IconType a long time ago so that I
wouldn't have to muck about with convoluted proceures in IconEd just to convert
an icon to a different type. At the time, I dug into the manuals and found what
I thought was all that was needed to change the icon's type. I guess I was
wrong. I do not plan on doing more to IconType, especialy since SIT is out
there from someone who apparently knows how it's done.

>So, Larry, did you actually test your program?

Apparently not enough. I changed a few icons that I found on a disk somewhere,
checked that they changed type by using INFO, and checked to see that the CLI
would then close. Sorry.

-larry

--
Frisbeetarianism: The belief that when you die, your soul goes up on
                  the roof and gets stuck.
+----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                |
| \X/    lphillips@lpami.wimsey.bc.ca or uunet!van-bc!lpami!lphillips  |
|        COMPUSERVE: 76703,4322                                        |
+----------------------------------------------------------------------+