Resourceforks 
Author Message
 Resourceforks

Hi,

I'm using the code below to list the resource names from a certain resource
type in my apps resourcefork and adding them to my popupmenu. One of my
resource names contains a "-" dash, which I want to replace with a divider
line in my popupmenu. My code doesn't work!!! It puts the line at the bottom
of the list, instead of the 5th place where it should be.

So resulting in, when calling the menu item from the popupmenu to retrieve
the resources data, one of them contains nothing (where the dash resource
is) and the last menu item (the separator in the popupmenu) can't retrieve
the resource information because you can't select them, and it's in the
wrong place anyway.

CAN ANYONE HELP???

Code:

  dim i as integer
  dim r as resourcefork
  r = app.resourcefork
  for i = 1 to r.resourcecount("Hlp1")
    If r.resourcename("Hlp1", i) = "-" then
      me.addseparator
    else
      me.addrow r.resourcename("Hlp1", i - 1)
    end if
  next
  me.listindex = 0

Here's what the popupmenu list looks like after calling the code:

item1
item2
item3
item4
item5
item6
- separator -

This is what it should look like:

item1
item2
item3
item4
- separator -
item5
item6

See ya :-)

-------------------------
Chris Willis

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



Mon, 12 Jan 2004 22:36:55 GMT  
 Resourceforks


Quote:
> Hi,

> I'm using the code below to list the resource names from a certain resource
> type in my apps resourcefork and adding them to my popupmenu. One of my
> resource names contains a "-" dash, which I want to replace with a divider
> line in my popupmenu. My code doesn't work!!! It puts the line at the bottom
> of the list, instead of the 5th place where it should be.

> So resulting in, when calling the menu item from the popupmenu to retrieve
> the resources data, one of them contains nothing (where the dash resource
> is) and the last menu item (the separator in the popupmenu) can't retrieve
> the resource information because you can't select them, and it's in the
> wrong place anyway.

> CAN ANYONE HELP???

> Code:

> dim i as integer
> dim r as resourcefork
> r = app.resourcefork
> for i = 1 to r.resourcecount("Hlp1")
> If r.resourcename("Hlp1", i) = "-" then
> me.addseparator
> else
> me.addrow r.resourcename("Hlp1", i - 1)
> end if
> next
> me.listindex = 0

> Here's what the popupmenu list looks like after calling the code:

> item1
> item2
> item3
> item4
> item5
> item6
> - separator -

> This is what it should look like:

> item1
> item2
> item3
> item4
> - separator -
> item5
> item6

> See ya :-)

> -------------------------
> Chris Willis

> -------------------------

Sorry but I missed a bit of code out, change the following line:

If r.resourcename("Hlp1", i) = "-" then

to:

If r.resourcename("Hlp1", i - 1) = "-" then

See ya :-)

-------------------------
Chris Willis

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



Mon, 12 Jan 2004 22:48:13 GMT  
 Resourceforks

Quote:

> Hi,

> I'm using the code below to list the resource names from a certain
> resource
> type in my apps resourcefork and adding them to my popupmenu. One of my
> resource names contains a "-" dash, which I want to replace with a
> divider
> line in my popupmenu. My code doesn't work!!! It puts the line at the
> bottom
> of the list, instead of the 5th place where it should be.

> So resulting in, when calling the menu item from the popupmenu to
> retrieve
> the resources data, one of them contains nothing (where the dash resource
> is) and the last menu item (the separator in the popupmenu) can't
> retrieve
> the resource information because you can't select them, and it's in the
> wrong place anyway.

> CAN ANYONE HELP???

Well, this is sheerly speculation since how you wrote the resources is
of vast importance but the resource index from resourcecount is
completely different from the ID number (such as you'd see in resedit or
resourcerer), which i suspect is what you ordered the list by. I'd get
the id by using r.resourceID("Hpl1",i-1) and after that, depending on
your application and it's, needs there a bajillion ways to solve the
problem, (i'd personally create a matching array of ids and string and
then sort both by ids)
anyways, i hope i was somewhat close ;)
--
If you build something from the inside out,
you'll have no difficulties penetrating from the outside in


Fri, 16 Jan 2004 23:13:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. FolderItem.ResourceFork resfNum How ?

2. Writing to the resourcefork

3. dragItems and resourceForks

4. ResourceFork

5. Resourcefork help

6. How do create a File and add ResourceForks

7. Problems with ResourceFork Class

8. Using App.ResourceFork HELP!

 

 
Powered by phpBB® Forum Software