Writing to the resourcefork 
Author Message
 Writing to the resourcefork

I've been trying to write a single char to a resourcefork but with the
following code it just won't work. The code is almost out of the book. The
editField "data.text" reads the existing resourcefork file which I make with
ResEdit, but I can't seem to write to it. Type and Creator by ResEdit.
Can someone help me with this?

dim r as resourceFork
dim s as string

  r=app.resourceFork

if ChBx.value=false then      //ChBx is a checkBox
    r.addResource(str(74), "STR", 15500, "pref")//this should overwrite data
else  
    r.addResource(str(66), "STR", 15500, "pref")    //str(66) = t
end

  r=app.resourceFork
  s = r.getResource("STR  ", 15500)

  data.text=s //it displays the data in existing resourceFork which is "t"

thanx
guy

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.*-*-*.com/ - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Sun, 24 Oct 2004 07:37:42 GMT  
 Writing to the resourcefork

writes:

Quote:
>  r=app.resourceFork

Well there's your problem. RealBasic does not allow you to modify the
running app's own resource fork. It is read-only.

 - Jeff



Sun, 24 Oct 2004 12:55:30 GMT  
 Writing to the resourcefork

Quote:

> Well there's your problem. RealBasic does not allow you to modify the
> running app's own resource fork. It is read-only.

And before you get pissed at REALsoftware over this, note that writing
to the app's resource fork is also frowned on by Apple and almost the
entire Mac programming community.  It's just not a good idea.

It looks like you're trying to write preference data to the app --
that's what preference files are for!  Use the PreferencesFolder method
to find the correct folder in which to save a prefs file.  Then you can
write resources to it to your heart's content!



Sun, 24 Oct 2004 23:17:22 GMT  
 Writing to the resourcefork

Quote:

> I've been trying to write a single char to a resourcefork

No, you're trying to write to the Application's resource fork (!):

Quote:
>   r=app.resourceFork

This is disallowed, for a variety of very good reasons.  Store your
preferences in a file in the PreferencesFolder instead.

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Thu, 28 Oct 2004 09:22:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. FolderItem.ResourceFork resfNum How ?

2. dragItems and resourceForks

3. ResourceFork

4. Resourceforks

5. Resourcefork help

6. How do create a File and add ResourceForks

7. Problems with ResourceFork Class

8. Using App.ResourceFork HELP!

9. self-booting pmode program written in assembler written in sh

10. Writing operators vs. writing procedures

11. Clarification: read/write slow, and TCPSocket and sys{read,write}

12. read/write slow, and TCPSocket and sys{read,write}

 

 
Powered by phpBB® Forum Software