IonicWind Software

IWBasic => General Questions => Topic started by: Jerry Muelver on February 02, 2009, 12:22:43 PM

Title: stack size
Post by: Jerry Muelver on February 02, 2009, 12:22:43 PM
Programming by RVA (Random Variable Assignment) instead of actual knowledge and training certainly has its challenges....

I'm pulling a 1.4 meg file out of "Resources" into a richedit control resized to 1600000. Couldn't do it at first, until I guessed that "stack size" would have something to do with limitations. So I increased the stack size for the project to 2097152 and it seems to work just fine. Is that enough for a 1.4 meg RTF string to live and breathe (and respond to @RTFINDTEXT, which it is doing quite well)? Should I be doing something about "commit stack size" as well?

Title: Re: stack size
Post by: Ionic Wind Support Team on February 02, 2009, 02:56:29 PM
You'll be fine.

Although I would never define a string that size on the stack, instead preferring to allocate them dynamically.
Title: Re: stack size
Post by: Jerry Muelver on February 03, 2009, 06:44:21 AM
Thanks, Paul. I'll look at dynamic allocation.... Hmm.... I think I'm doing that already.

I'm doing this:
DEF buffer: pointer
buffer = new(char,1600000)
...
CONTROL d1,@RICHEDIT,"",7,350,570,80,0x50B000C4,10
...
CONTROLCMD d1,10,@RTSETLIMITTEXT,1600000

And then use it thus:
flen = LOADRESOURCE(333,324, buffer)
CONTROLCMD d1, 10, @RTLOAD, #<string>buffer, 0

It just now occurred to me -- should I do a DELETE on "buffer"? The only use is to get the resource loaded into the richtext control.
Title: Re: stack size
Post by: Ionic Wind Support Team on February 03, 2009, 09:10:38 AM
Yes you should be deleting the buffer.

Paul.
Title: Re: stack size
Post by: Jerry Muelver on February 03, 2009, 09:23:14 AM
Use it, and throw it away, hey? Okay, thanks!