🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #19068

Re: ParamText Question

#19068
From: Eric Olson
Date: Mon, 14 Sep 1987 18:11
66 lines
2583 bytes
In article <73@ur-tut.UUCP> dagl@ur-tut.UUCP (Dave Glowny) writes:
>The problem I've encountered is that when the string contains one of the
>ParamText keys (^0,^1,^2,^3) the ParamText strings are substitued in place.
>For example, if the user enters "x^2" in the f(x) box in my dialog, the next
>dialog invocation will show f(x) with the default value of "x", substituting
>the null string for ^2. (I do use ParamText1 for my alerts, but I pass null
>strings for the other 3 arguments)
>
>Is there any way to disable this substitution process ?  I attempted
>ParamText("\P^0","\P^1","\P^2","\P^3"); but this only caused an infinte loop
>of substitution as I observed with TMON.

This is not a solution, but a praise of ParamText.  You can't define ParamText
1 to be "^1" because it does the substitution in an infinite loop.  But this
is very convenient, since your error function could be:

	myerr(errnum,paramnum,errfn)
	long		errnum;
	long		paramnum;
	char *		errfn;
{
	char		numstr[20];
	char		parmstr[20];
	StringHandle	errstr;

	NumToString(errnum,numstr);
	NumToString(paramnum,parmstr);
	errstr=GetString(errnum);
	
	HLock(errstr);
	ParamText(*errstr,numstr,parmstr,errfn);

	do_error_alert();

	HUnlock(errstr);
	}

Now, if errnum is -108 and STR -108 is "Out of memory (need ^1 more bytes)
while ^2.", and the error call is 

	myerror(-108,needed-got,"\pallocating buffer")

then the dialog will acutally say:

	Out of memory (need 28934 more bytes) while allocating buffer.

Similarly, you could have a rangecheck error called like:

	myerror(300,value,"\pstart point")

where STR 300 is:

	"The value of ^2 (^1) is out of range."

Then the dialog will actually say:

	"The value of start point (234) is out of range."

Anyways, I use the ParamText a lot like this and find that, because it
isn't just a one-level substitution, it's very easy to make error messages
that look good.

-Eric


Eric K. Olson		olson@endor.harvard.edu		harvard!endor!olson
Technical Details
Message-ID: <2837@husc6.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!ll-xn!husc6!endor!olson
References: <73@ur-tut.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!ll-xn!husc6!endor!olson
From: olson@endor.harvard.edu (Eric Olson)
Newsgroups: comp.sys.mac
Subject: Re: ParamText Question
Message-ID: <2837@husc6.UUCP>
Date: Mon, 14-Sep-87 14:11:45 EDT
Article-I.D.: husc6.2837
Posted: Mon Sep 14 14:11:45 1987
Date-Received: Tue, 15-Sep-87 06:21:55 EDT
References: <73@ur-tut.UUCP>
Sender: news@husc6.UUCP
Reply-To: olson@endor.UUCP (Eric Olson)
Organization: Aiken Computation Lab Harvard, Cambridge, MA
Lines: 66