Author |
Message |
wppk
Joined: Jan 25, 2008 Posts: 31 Location: Los Angeles
|
Posted: Wed Feb 13, 2008 4:13 pm Post subject:
Question regarding cap() and other member functions |
|
|
What is the cap() function. What class is it a part of. Is there any documentation listing the various data and function members of the inherent classes in the CHUCK language? |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Feb 14, 2008 7:25 am Post subject:
|
|
|
.cap() is a member of the array object. If invoked for a given array it returns it's length. The only other functions of build-in classes I can think of right now are ".broadcast()" and ".signal()" for events.... Well and maybe ".send()" for MidiOut and the members of the various messages (HID, MIDI, etc) These should all be in the manual in the explanation of the classes they belong to, if they are not that would be cause for a little note on the "manual errata" wiki page.
Code: |
//define a array of type integer and length 8;
int foo[8];
//verify the length;
<<<foo.cap()>>>;
//more complicated example for 2d arrays
//this can be seen as "a array of arrays"
float bar[4][5];
//check how many arrays we have
<<<bar.cap()>>>;
//check the length of the first one
<<<bar[0].cap()>>>;
//change it
[1.0, 2.1, 3.2] @=> bar[0];
//check the length of the (now changed) first one
<<<bar[0].cap()>>>; |
Does that help? _________________ Kassen |
|
Back to top
|
|
|
wppk
Joined: Jan 25, 2008 Posts: 31 Location: Los Angeles
|
Posted: Thu Feb 14, 2008 1:51 pm Post subject:
|
|
|
Yes thanks.
But if you look at the some of the examples, joy.ck for instance, there seem to be member functions for the Hid class that are not in the manual.
if( !hi.openJoystick( device ) ) me.exit();
if( msg.isAxisMotion() )
else if( msg.isButtonDown() )
Please forgive my ignorance but these functions don't seem to have been declared from within the file so I'm assuming that they are inherent to the Hid class. Am I correct? |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Feb 14, 2008 4:17 pm Post subject:
|
|
|
Oh, oops, yes. You are right.
Those are extra functions, mostly for convenience that got added to the HID after the HID had been put in the manual. They work like you'd expect them to; msg.isAxisMotion() returns 1 if the message is of that type. I should mention that these are not, strictly speaking, members of the "HID" object and instead are properties of the hid message received by the HID object.
".openJoystick( device )" would be the exception, that one is a member function of the hid object itself.
For these I'd say you are much better off with the examples then with the manual. _________________ Kassen |
|
Back to top
|
|
|
wppk
Joined: Jan 25, 2008 Posts: 31 Location: Los Angeles
|
Posted: Thu Feb 14, 2008 4:41 pm Post subject:
|
|
|
Thanks Kassen.
I just have one more question pertaining to this subject.
What is the .arg() function? |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Feb 15, 2008 9:38 am Post subject:
|
|
|
You're welcome!
But, erm, .arg()? Where did you find that? Sounds like one of the member functions of some Ugens that got carried over from the STK? Something to set a whole set of parameters in one swoop?
Typically I don't really use those and instead use the ones aimed more squarely at ChucK which I find more readable. Still, those are documented quite well in the Ugen docs, I think?
Could you point me to the exact source of your confusion? I think this process is quite valuable, BTW, it's great feedback about the docs, everybody knows those needs to be maintained but it's much harder to say exactly *what* should be in them, where and how. In my opinion; if somebody makes a real effort to look stuff up yet it's still unclear that means the docs are to blame. _________________ Kassen |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Feb 15, 2008 10:00 am Post subject:
|
|
|
By the way, I just looked it up and the HidMsg functions you were after turn out to be quite well documented after all. Admittedly it's the final entry in the manual but it's there and quite clear.
I can't find .arg() at all in the whole manual and not in the online Ugen specifications either. "arg" does get used as a name for a argument relatively often, but that's only to indicate the purpose of that variable, it could be called "foo" just as well in those contexts. _________________ Kassen |
|
Back to top
|
|
|
wppk
Joined: Jan 25, 2008 Posts: 31 Location: Los Angeles
|
Posted: Fri Feb 15, 2008 1:24 pm Post subject:
|
|
|
you're right. They are in the manual. I just never made it that far assuming that they would be elsewhere in the manual.
As far as .arg(), I've seen it everywhere and now i can't seem to find it anywhere.
I'll post an example when I come across one. |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Feb 15, 2008 2:25 pm Post subject:
|
|
|
wppk wrote: | you're right. They are in the manual. I just never made it that far assuming that they would be elsewhere in the manual. |
I understand. Once you get up to speed the final chapters of the manual are the best stuff; they are a great reference but indeed you need the earlier chapters to make use of them.
Quote: | As far as .arg(), I've seen it everywhere and now i can't seem to find it anywhere.
I'll post an example when I come across one. |
I think I remember it as well. For one thing; I do believe you will be fine without ever using it and when you need it it'll be clear because then you know the context and will run into it naturally. No need to know everything by heart, if .arg() were vitally important on a daily basis I'm sure it would've had a better name, even ".coefs()" (for filters and the "gen" tables) does.
:¬) _________________ Kassen |
|
Back to top
|
|
|
|