Re: File Style
Quote from Forum Archives on November 27, 1997, 6:27 pmPosted by: rbrown <rbrown@...>
Brian wrote:
> I'd like to know what the "best" way is to attach data to a window,
> avoiding global variables if at all possible. I'm thinking along the lines
> of giving a window a pointer to a data structure when I open it. The data
> structure would contain a handle to the file, file prefs, etc. The demos
> I've seen have all either stored such information in a global or in an edit
> field in the window. If a global variable is necessary, how can I attain
> this as simply and as efficiently as possible?Something I've done in the past is this: create an array of global
long-integers, like this:DIM gWindowDataH&(255)
Then, when you create window "n", allocate a relocatable block of
whatever size is appropriate, and store its handle in gWindowDataH&(n).
For example:gWindowDataH&(windowID) = FN NEWHANDLE(_dataSize)
Now you have an easily-identifiable block of data for every window.
- Rick
Posted by: rbrown <rbrown@...>
> I'd like to know what the "best" way is to attach data to a window,
> avoiding global variables if at all possible. I'm thinking along the lines
> of giving a window a pointer to a data structure when I open it. The data
> structure would contain a handle to the file, file prefs, etc. The demos
> I've seen have all either stored such information in a global or in an edit
> field in the window. If a global variable is necessary, how can I attain
> this as simply and as efficiently as possible?
Something I've done in the past is this: create an array of global
long-integers, like this:
DIM gWindowDataH&(255)
Then, when you create window "n", allocate a relocatable block of
whatever size is appropriate, and store its handle in gWindowDataH&(n).
For example:
gWindowDataH&(windowID) = FN NEWHANDLE(_dataSize)
Now you have an easily-identifiable block of data for every window.
- Rick