🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #3482

Re: gadgets in 2.0

#3482
From: John J. Szucs
Date: Mon, 07 May 1990 00:18
82 lines
3365 bytes
In article <1990May6.183020.17956@calgary.uucp> pepers@enme3.UUCP (Brad Pepers) writes:
>
>I read the other day about how there is a new gadget library that does all
>sorts of wonderful things for you. This is of course GREAT.... BUT.....
>
>The calling convention of the functions was something like:
>
>     funcion(param1,param2,...,paramN,tag1,val1,tag2,val2,....);
>
>Where param? are necessary params and the rest are tag/value combinations
>with no particular type or number of them.
>
>My problem is this: while this is ok for C (but you don't get type checking
>and "safe" things like that) its not ok for most other languages. There is no
>way to declare a routine like that for Pascal, Modula2, etc... They just
>don't allow variable parameter lengths. So these wonderful new functions
>can't be used by anything but C and assem!!!
>
>Why couldn't the gadget routines take a pointer to a variable length 2D
>array with tag,value pairs? This would be supportable in all languages.
>
>Am I right about this or is there something I've missed??
>

The variable argument functions in 2.0 are called as follows:

void MyFunction()
{
	struct NewMenu MyNewMenu;
	struct Menu *MyMenu;

	/* initialize my new menu */
	...

	/* create MyMenu from specification in MyNewMenu with front pen of 0 */
	MyMenu=CreateMenusA(&MyNewMenu,GTMN_FrontPen,0,TAG_DONE,NULL);

	/* do other stuff */
}

If your language (or compiler) does not support variable argument functions,
you can pass an array of TagItems to a function that expects them, like this:

void MyFunction()
{
	struct NewMenu MyNewMenu;
	static struct TagItem MyTagList[] ={
		GTMN_FrontPen, 0,
		TAG_DONE, NULL,
	};

	/* Initialize my new menu */
	...

	/* create MyMenu from specification in MyNewMenu
	   and tags in MyTagList */
	MyMenu=CreateMenusA(&MyNewMenu,&MyTagList);

	/* do other stuff */
}

Basically, you can pass a pointer to an array of TagItems, with the type
of last one being TAG_DONE, and the results will be the same as passing
a set of tags as parameters to the function.

Notes:

CreateMenusA is a function that accepts a pointer to a NewMenu structure
and a list of tags and returns a pointer to a Menu structure.

TAG_DONE is a special tag type indicating the end of the list of tags.

>    Brad Pepers

================================================================================
|| John J. Szucs                    || The opinions expressed are my own and  ||
|| Systems Evaluation Group         || in no way represent the opinions or    ||
|| Product Assurance Department     || policies of Commodore Technology, Inc. ||
|| Commodore Technology, Inc.       || or any associated entity.              ||
================================================================================
...{rutgers|uunet|pyramid}!cbmvax!jjszucs
jjszucs@cbmvax.commodore.com
Technical Details
Message-ID: <11397@cbmvax.commodore.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cbmvax!jjszucs
References: <1990May6.183020.17956@calgary.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cbmvax!jjszucs
From: jjszucs@cbmvax.commodore.com (John J. Szucs)
Newsgroups: comp.sys.amiga.tech
Subject: Re: gadgets in 2.0
Keywords: gadgets 2.0
Message-ID: <11397@cbmvax.commodore.com>
Date: 7 May 90 00:18:28 GMT
References: <1990May6.183020.17956@calgary.uucp>
Reply-To: jjszucs@cbmvax (John J. Szucs)
Organization: Commodore, West Chester, PA
Lines: 82