templates and parameters

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

templates and parameters

Post by mwieder » Fri Mar 11, 2016 1:47 am

I'm working on implementing an optional argument for the files() and folders() functions.
I've got things to the point where the parser will accept a parameter or not, and I'm returning the same result in each case.
So far so good.

But I'm stuck trying to implement the exec part of this. Both functions are currently implemented with a template that doesn't take arguments. I see a template for a variable number of math arguments, and I see one that requires a *lot* of rework of the affected functions and all I've been able to do when it finally compiles is throw a segment fault. I'm assuming I have to invoke get0or1parameters at some point, but it's looking like I'll have to create a new type of template for this situation, and that doesn't seem right.

So I'm going on the assumption that I'm missing something obvious, and maybe there's another function already doing this that I can use as a model.

I'm up for any ideas. I've had to modify seven files to get this far.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: templates and parameters

Post by LCMark » Fri Mar 11, 2016 5:41 pm

@mwieder: There isn't a template for functions which take 0 or 1 parameters... If you make MCTheFiles (and the folder variant) inherit from MCFunction again, just reinstate similar logic as is present in the MCMouse function class.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: templates and parameters

Post by LCMark » Fri Mar 11, 2016 5:49 pm

Btw - I take it you found that MCSystemInterface ListFolderEntries already supports a folder parameter - I believe @peter-b added that a while back, but we never got around to exposing it to script.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: templates and parameters

Post by mwieder » Fri Mar 11, 2016 7:39 pm

@LCMark - thanks, I'll poke around a bit more. Actually, the MCMouse class is what I was using as my model, since it can take an optional parameter, but I haven't yet found the secret key, since I just threw a segfault when I finally got code that compiled.

And no, I did *not* notice Peter-B's addition. I'll go dive in there.

Locked

Return to “Engine Contributors”