Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 01-20-2019, 12:48 PM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default Extension API: Optional boolean parameter "unsupported" in IDE and API help

Optional parameters can be added to extension-provided API functions by adding the "Optional" suffix to parameter names:

Quote:
// When defining/documenting API function parameters:
// - if a (char*,int) pair is encountered, name them buf, buf_sz
// - if a (const char*,int) pair is encountered, buf, buf_sz as well
// - if a lone basicType *, use varNameOut or varNameIn or
// varNameInOptional (if last parameter(s))
bool* myNameOptional works fine, and if the script does not omit the optional parameter, the IDE will only accept boolean input.

However, in the API help webpage and in the IDE inline help, the parameter type is named "unsupported":

Code:
Lua: identifier reaper.JS_Mouse_LoadCursorFromFile(string pathAndFilename, unsupported forceNewLoad)
juliansader is offline   Reply With Quote
Old 05-31-2020, 01:49 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Bumpelicious. This is important to be shown correctly in the docs.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-31-2020, 02:41 PM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,093
Default

I think (but not sure, or maybe this got changed/fixed at some point) the 'trick' is to name a parameter blahInOptional or blahOutOptional, that works for these API function for optional int/numbers at least.

BR_EnvGetProperties:

Code:
boolean active, boolean visible, boolean armed, boolean inLane, number laneHeight, number defaultShape, number minValue, number maxValue, number centerValue, number type, boolean faderScaling, optional number automationItemsOptions = reaper.BR_EnvGetProperties(BR_Envelope envelope)
BR_EnvSetProperties:

Code:
reaper.BR_EnvSetProperties(BR_Envelope envelope, boolean active, boolean visible, boolean armed, boolean inLane, integer laneHeight, integer defaultShape, boolean faderScaling, optional number automationItemsOptionsIn)
edit:
I haven't tried if this also works for an optional boolean parameter though.

edit2:
Ok, for an optional boolean input parameter I think I can confirm it doesn't work quite right.
Code:
C: const char* ULT_GetMediaItemNote(MediaItem* item, bool blahInOptional)

EEL: bool extension_api("ULT_GetMediaItemNote", #retval, MediaItem item, bool blahIn)

Lua: string reaper.ULT_GetMediaItemNote(MediaItem item, boolean blahIn)

Python: String ULT_GetMediaItemNote(MediaItem item, Boolean blahInOptional)

Last edited by nofish; 05-31-2020 at 03:31 PM.
nofish is offline   Reply With Quote
Old 05-31-2020, 03:08 PM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

I link this post, in which Julian and I were discussing this and other parser-problems for the helpgeneration.

https://forum.cockos.com/showpost.ph...postcount=1275
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-12-2022, 12:39 PM   #5
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Just a little bump for this 4-year-old bug.
juliansader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.