Path: utzoo!attcan!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.sys.atari.st Subject: Re: Resource / fsel_input() problem Message-ID: <913@philmds.UUCP> Date: 7 Jan 89 11:14:45 GMT References: <908@philmds.UUCP> <826@laura.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 48 In article <826@laura.UUCP> klute%trillian.irb@unido.UUCP (Rainer Klute) writes: |In article <908@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) [that's me] writes: |>Using the resource functions (notably rsrc_load(), rsrc_gaddr(), |>rsrc_free()) I can load resources that, for instance, contain object |>trees like forms and menus. Nice. |> |>Using fsel_input() I have a standard way for the user to search and |>specify a pathname (directory and filename). Also nice. |> |>But trying to use both in the same program failed; when an fsel_input() |>was done after a rsrc_load() the resource tree contained garbage. |>It looks as if fsel_input() uses the rsrc_load() function itself, and |>since a program can only have one resource file loaded at a time (am I |>correct ?), it put its own resource on top of mine. | |I'm quite surprised to hear about such a behavior of your |program. I use the same sequence (rsrc_load, fsel_input) over |and over again in my programs and *never* encountered such a |bug. I guess it is a bug in your own code. Trying and retrying with new and old versions of my program (the new version did NOT have the problem) I found the cause of the trouble: The initial startup code that Lattice C (the compiler I'm using) adds to a program, ensures that the program uses all but 4K of memory. This is the default; it can be overruled by specifying a value for the (global) variable _mneed, which sets the memory needed explicitly, or by supplying a commandline parameter for the program of the form %workspace. The old version (the one with the problem) used the default memory scheme ("all but 4K"). The resource file I was using was about 2K. If I'm correct, resource files are loaded into remaining memory, so that was the cause of the trouble (4K - 2K == 2K remains, what proved to be too little for whatever tricks fsel_input had to perform). (Funny detail: when I used the default memory scheme on the new version, fsel_input returned immediately). Moral: always ensure that your program using resource files leaves enough remaining memory for these files to get loaded (and some 4K extra too). Perhaps it had been better if rscr_load refused to load into such a small remaining amount of memory, or fsel_input complained about lack of memory. Well, you can't have it all... Sorry if I caused any confusion on the net, but I think this is a useful lesson anyway. Cheers! Leo.