h1

NoteTab Clipping – Detect Parameter Passing

27/01/2009

When working with NoteTab clips I like to be efficient and reuse clips just like programmers do with functions, subroutines, code libraries, etc. So one little thing I like to use when dealing with some clips is a conditional statement that allows the clip to work out if it was called from another clip with a parameter.

To accomplish this we’re actually going to use something that the NoteTab Clip help file recommends against – converting 4 (decimal) to a character using the ^$DecToChar()$ function. ASCII(004) is an end of transmission character, but it turns our that we can test against this on the parameter place holder. Just trying to measure the size as zero when a parameter is passed for example curiously gives a length of two characters.

^!If ^& > ^$DecToChar(4)$^$DecToChar(4)$ PARAM_PASSED Else NO_PARAM

The two go to labels used here show the logic. PARAM_PASSED is where a parameter has been passed and NO_PARAM is where no parameter was passed.

This snippet of code is useful because it can be used for example at the start of a clip that could be run manually by a user taking in a parameter through an input box. It can also be used at the end in determining how to deal with a result – display it, insert it, pass it back in the %RESULT% variable, etc.

Please note that the code does not distinguish between a clip called with no parameters from another clip and a clip run manually. Of course if the clip is called from another clip using a dummy parameter it could be used as a crude way of doing this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: