Re: [ooc-compiler] Choosing sufficiently long array for out parameter
Brought to you by:
mva
|
From: August K. <fus...@co...> - 2005-12-06 18:13:14
|
Michael van Acken wrote: > On 29/11/05, *August Karlstrom* <fus...@co... > <mailto:fus...@co...>> wrote: > > Hi, > > The procedure GetText in Msg has the signature > > PROCEDURE (msg: Msg) GetText(VAR text: ARRAY OF CHAR) > > How do I make sure the message fits in `text'? > > > > Beforehand, you can't. What you can do is check if the result > maxes out the array, and call again with a larger array if this > is the case. Repeat until not maxed out. Not very elegant, I > know :-) OK, I see. This is (of course) a general problem in Oberon. In C we can just return a pointer to a constant string so there is no need to either allocate a buffer or know the size of it. In defense of Oberon, a C program may crash if we inadvertently try to write to a constant string. Still a bit annoying though. August |