Below is my first plugin for Lintalist.
It produces an Ordinal Indicator for a number. That is the "st nd rd th" that goes after a number in English.
[[OrdinalIndicator=3]] will produce "rd"
[[OrdinalIndicator=3|]] will produce "3rd"
Code: Select all
/*
Plugin : OrdinalIndicator
Purpose : Insert ordinal indicator for number (st nd rd th)
Version : 1.0
Author : FanaticGuru
*/
GetSnippetOrdinalIndicator:
Loop
{
If (InStr(Clip, "[[OrdinalIndicator=") = 0) or (A_Index > 100)
Break
If InStr(PluginOptions,"|") ; Insert after number if option otherwise replace number
PluginSnippetVariable := StrSplit(PluginOptions,"|").1 OrdinalIndicator(StrSplit(PluginOptions,"|").1)
else
PluginSnippetVariable := OrdinalIndicator(PluginOptions)
StringReplace, clip, clip, %PluginText%, %PluginSnippetVariable%, All
PluginSnippetVariable:=""
PluginOptions:=""
PluginText:=""
ProcessTextString:=""
}
Return
OrdinalIndicator(n)
{
return Mod(n+9,10)>=3||Mod(n+89,100)<3?"th":Mod(n,10)=1?"st":Mod(n,10)=2?"nd":"rd"
}
This was mainly done to learn about how to make Lintalist plugins.
I really like Lintalist. It is one of the scripts I always have running. But I was not too crazy about the plugin system. It took me longer than it seems like it should have for me to read and understand how to create my first plugin.
It would seem so much easier and intuitive if plugins were just "functions". As opposed to the current system of gosubs with global variables that creates an overhead that you have to understand of how input and output works with the gosubs. Functions inherently already have an understood system of input through parameters and output through return.
[[OrdinalIndicator(1234)]] would seem so much easier to understand in the Lintalist markup, in the creation of the plugin, and even in the source coding of Lintalist. Just put a bunch of custom functions in a folder and those functions then become useable in the Lintalist markup.
It would be great if I could just copy a dozen functions that I already have for things like putting commas in numbers, formatting money, padding strings, various string manipulations, etc. (basically standard function from my AHK library) into a folder with no modification and then have them available to use in Lintalist.
Maybe a dual system where
<<OrdinalIndicator(1234)>> indicates a custom function and not a plugin.
There might be other problems with this approach that I have not thought about and it would be a major modification at this point. Just my feedback. The most important feedback being that I really do like Linalist.
FG