[SOLVED] How is the %WORD parameter used when coding a tool ?

Working on new editor enhancements?
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

[SOLVED] How is the %WORD parameter used when coding a tool ?

Post by Blue »

I'm running a very simple tool for setting the caret in the PB editor,
a tool someone gave me, but I forget who it was.
The tool works perfectly with the latest Scintilla version, but I'd like to make it a little flexible.

The Caret Tool is simply these 2 lines :

Code: Select all

ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
SendMessage_(ScintillaHandle, #SCI_SETCARETWIDTH, 9, 0)
Now I'd like to do something like this, using the %WORD parameter :

Code: Select all

ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))

n = val(%WORD)
if n<3
  n = 3
endif

SendMessage_(ScintillaHandle, #SCI_SETCARETWIDTH, n, 0)
where the word under the caret would be 7 or 8 or 9 or whatever.

Can someone show me how that can be done ?
Last edited by Blue on Mon Feb 05, 2024 6:39 am, edited 2 times in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
jassing
Addict
Addict
Posts: 1771
Joined: Wed Feb 17, 2010 12:00 am

Re: How is the %WORD parameter used when coding a tool ?

Post by jassing »

You don't use "%word" in your program, you pass it as a parameter to your compiled program
AZJIO
Addict
Addict
Posts: 1360
Joined: Sun May 14, 2017 1:48 am

Re: How is the %WORD parameter used when coding a tool ?

Post by AZJIO »

Code: Select all

Word$ = GetEnvironmentVariable("PB_TOOL_Word")
Run this compiled file as a tool and get the output of all variables.

Code: Select all

OpenConsole()
If ExamineEnvironmentVariables()
    While NextEnvironmentVariable()
        PrintN(EnvironmentVariableName() + " = " + EnvironmentVariableValue())
    Wend
EndIf
PrintN("")
PrintN("Нажмите Ввод для выхода.")
Input()
Here they are

Code: Select all

PB_TOOL_Compiler = C:\...\pbcompiler.exe
PB_TOOL_Cursor = 2x2
PB_TOOL_Debugger = 1
PB_TOOL_Executable =
PB_TOOL_FileList = C:\...\getprocesslist.pb
PB_TOOL_IDE = C:\...\PureBasic.exe
PB_TOOL_InlineASM = 1
PB_TOOL_Language = English
PB_TOOL_MainWindow = 68968
PB_TOOL_OnError = 0
PB_TOOL_Preferences = C:\...\PureBasic.prefs
PB_TOOL_Scintilla = 5313694
PB_TOOL_Selection = 2x2x2x2
PB_TOOL_SubSystem =
PB_TOOL_Thread = 0
PB_TOOL_Unicode = 1
PB_TOOL_Word = Debug
PB_TOOL_XPSkin = 1
Including you will get a bunch of other variables such as %Path% etc.
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: How is the %WORD parameter used when coding a tool ?

Post by Blue »

AZJIO wrote: Thu Jul 06, 2023 4:48 am

Code: Select all

Word$ = GetEnvironmentVariable("PB_TOOL_Word")
Thank you AZJIO
That's the part ("PB_TOOL_Word") I didn't know.
My Caret.exe app now has more flexibility and agility, and it works to my liking.

May I ask where you found out that you had to use ("PB_TOOL_Word") to access the %WORD variable ? I searched the help file thoroughly and didn't find any mention of this.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: How is the %WORD parameter used when coding a tool ?

Post by Blue »

Following the information received from AZJIO,
I reworked my Caret.exe tool as follows :

Code: Select all

ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
;; 2 4 6 8 10 12 14 16 18 20
word$= GetEnvironmentVariable("PB_TOOL_Word")
n = Val(word$)
If n<2 Or n>20 
  n = Val(ProgramParameter(0))
  If n<2 Or n>20   ;; maybe NO default value was specified on the command line  
    n = 5
  EndIf
EndIf
SendMessage_(ScintillaHandle, #SCI_SETCARETWIDTH, n, 0)
End
Tool name : Caret.exe
Arguments: 7;%WORD
Event to trigger: Sourcecode loaded

So, by default, the caret width will be 7 since, upon opening a file, the caret will not be over a number string.
If the user places the caret on a number between 2 and 20, and then calls the Caret tool, the caret will change to that value. Very practical (if you use a high def display, you'll know what I'm talking about)

Now, if I could figure out how to combine 2 event triggers, I could automate the caret adjustement when opening a new file as well. Maybe in some other life...
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Post Reply