How to use "script snippets" within "choice"? #209
Replies: 1 comment 1 reply
-
Not directly as you noticed. But it can be done in two ways.
One snippetCreate one snippet, with a script that has all the "scripts" so to speak. That may not be diserable as you can no longer execute individual scripts without selecting which one. But it might work for you. Part1
Script - see See https://lintalist.github.io/#script-plugins for #NoEnv
#SingleInstance, force
SetBatchLines, -1
[[llpart1]]
Gosub, %llpart1%
ExitApp
Return
Script1:
MsgBox Script1
Return
Script2:
MsgBox Script2
Return Create a pluginSee https://github.com/lintalist/lintalist/blob/master/plugins/readme-howto.txt for background info a. Save this as /*
Plugin : XSnippet
Purpose : eXecute snippet
Version : 1.0
History:
- 1.0 first version
*/
GetSnippetXSnippet:
Loop ; daisy chaining snippets
{
If (InStr(Clip, "[[XSnippet=") = 0) or (A_Index > 100)
Break
Loop, % Snippet[Paste1].MaxIndex()
{
If (Snippet[Paste1,A_Index,4] = PluginOptions) ; shorthand
{
script:=Snippet[Paste1,A_Index,5] ; script
Break
}
}
clip:=""
FileDelete, %TmpDir%\tmpScript.ahk
StringReplace, Script, Script, LLInit(), %LLInit%, All
Loop {
If (InStr(Script, "[[Var=") = 0)
break
RegExMatch(Script, "iU)\[\[Var=([^[]*)\]\]", ClipQ, 1)
StringReplace, Script, Script, [[Var=%ClipQ1%]], % LocalVar_%ClipQ1%, All ; %
}
Loop, 2 ; check for plugins llpart1 and llpart2
{
If InStr(Script,"[[llpart" A_Index "]]")
{
Clip:=Text%A_Index%
Gosub, ProcessText
ParseEscaped()
Gosub, CheckLineFeed
If CancelPlugin
{
If TryClipboard()
Clipboard:=ClipSet("g",1,SendMethod)
ClipSet("ea",1,SendMethod)
ClearVars()
Return
}
Clip:=CheckCursorPos(Clip)
; we use (join`n % here to avoid the need to escape the % characters which may be included in the clip variable - https://github.com/lintalist/lintalist/issues/92
StringReplace,Script,Script,[[llpart%A_Index%]],llpart%A_Index%=`n(join``n `%`n%clip%`n)`n`nLLBackLeft%A_Index%:=%BackLeft%`nLLBackUp%A_Index%:=%BackUp%`n`n,All
BackLeft:=0
BackUp:=0
}
}
FileAppend, % Script, %TmpDir%\tmpScript.ahk, UTF-8 ; %
;FileCopy, %TmpDir%\tmpScript.ahk, saved.ahk , 1 ; debug
GUI, 1:Destroy
RunWait, %A_AhkPath% "%TmpDir%\tmpScript.ahk"
FileDelete, %TmpDir%\tmpScript.ahk
Script=
If Statistics
Stats("Scripts")
PluginOptions:=""
PluginText:=""
ProcessTextString:=""
}
Return |
Beta Was this translation helpful? Give feedback.
-
Hello together :)
I use 1.9.14
I am referenceing snippets within the choice function like so
[[Choice=?!Topic|[[Snippet=teamsSurvive]]|[[Snippet=teamsUseVideo]]]]
Each snippet has a script configured, down in the script section. However each script also has a description in the "part 1" section. This is the section that will be displayed by the choice function.
After picking a snippet from the list, how do I force lintalist to excute the script insead of inserting the text from "part 1" ??
Beta Was this translation helpful? Give feedback.
All reactions