- Aug
- 2,058
- 83
Below is an example script that allows you to determine the status of a Plugin, and load/UnLoad the Plugin.
Note that you must change line 21 to reflect the location of your plugins.
You will have to modify the code to reflect the plugins that you use.
In this first example, the asterisk indicates that the FedUtils8 plugin is loaded. To unload the FedUtils8 plugin, simply highlight this row, and press Enter.
1) ISO8601
2)*FedUtils8
3) SafeChars
4) Exit This Menu
In this next example, the asterisk indicates that the ISO8601 and SafeChars plugins are loaded. To unload them, simply use the arrow keys to move the highlight, and press Enter.
1)*ISO8601
2) FedUtils8
3)*SafeChars
4) Exit This Menu
Joe
Code:
@echo off
setlocal
::------------------------------------+
:: Clean up the environment |
::------------------------------------+
unalias *
unset *
if %@arrayinfo[Menu,0] eq 1 unsetarray Menu
::------------------------------------+
:: Create an array of Menu options |
::------------------------------------+
setarray Menu[4]
set Menu[0]=%@if[plugin iso8601,1)*ISO8601,1) ISO8601]
set Menu[1]=%@if[plugin FedUtils8,2)*FedUtils8,2) FedUtils8]
set Menu[2]=%@if[plugin SafeChars,3)*SafeChars,3) SafeChars]
set Menu[3]=4) Exit This Menu
set MaxRow=%@eval[%@arrayinfo[Menu,1]-1]
::----------------------------------------------+
:: Location of plugins |
::----------------------------------------------+
set plugindir=c:\utils
::----------------------------------------------+
:: Find the length of the longest menu item |
::----------------------------------------------+
set MaxLen=0
do therow=0 to %MaxRow
if %@len[%Menu[%therow]] gt %MaxLen set MaxLen=%@len[%Menu[%therow]]
enddo
::------------------------------------+
:: Draw a box for the Menu |
::------------------------------------+
cls
drawbox 0 0 %@eval[%MaxRow+2] %@eval[%MaxLen+1] 1 bri whi on blu fill blu
set currentrow=0
::------------------------------------+
:: Draw the Menu |
::------------------------------------+
gosub DrawMenu
::------------------------------------+
:: Process user input |
::------------------------------------+
do forever
do forever
screen %@eval[%MaxRow+3] 0
inkey /P %%option
:: @28 - Enter
if %option eq @28 leave
:: @80 - Down Arrow
if %option eq @80 set currentrow=%@inc[%currentrow]
:: @72 - Up Arrow
if %option eq @72 set currentrow=%@dec[%currentrow]
:: @79 - End
if %option eq @79 set currentrow=%MaxRow
:: @71 - Home
if %option eq @71 set currentrow=0
if %currentrow gt %MaxRow set currentrow=0
if %currentrow lt 0 set currentrow=%MaxRow
::--------------------------------+
:: Check for a number |
::--------------------------------+
iff %option gt 0 .and. %option lt %@eval[%MaxRow+2] then
set currentrow=%@eval[%option-1]
gosub DrawMenu
leave
endiff
::--------------------------------+
:: Draw the Menu |
::--------------------------------+
gosub DrawMenu
::--------------------------------+
:: Go back and process user input |
::--------------------------------+
enddo
::----------------------------------+
:: A Menu option was selected |
:: Take the chosen route |
::----------------------------------+
set option=%@inc[%currentrow]
if %option eq 1 gosub option1
if %option eq 2 gosub option2
if %option eq 3 gosub option3
if %option eq 4 leave
::--------------------------------+
:: Draw the Menu |
::--------------------------------+
gosub DrawMenu
enddo
::------------------------------------+
:: Exit This Menu |
::------------------------------------+
if %@arrayinfo[Menu,0] eq 1 unsetarray Menu
endlocal
::------------------------------------+
:: Return to command prompt |
::------------------------------------+
quit
::----------------------------------+
:: Draw the Menu |
::----------------------------------+
:DrawMenu
do therow=0 to %MaxRow
if %therow eq %currentrow scrput %@eval[%therow+1] 1 bri blu on whi %Menu[%therow]
if %therow ne %currentrow scrput %@eval[%therow+1] 1 bri whi on blu %Menu[%therow]
enddo
return
::------------------------------------+
:: Option 1 |
::------------------------------------+
:option1
iff plugin iso8601 then plugin /u iso8601 %+ else %+ plugin /l %plugindir\iso8601 %+ endiff
set Menu[0]=%@if[plugin iso8601,1)*ISO8601,1) ISO8601]
return
::------------------------------------+
:: Option 2 |
::------------------------------------+
:option2
iff plugin FedUtils8 then plugin /u FedUtils8 %+ else %+ plugin /l %plugindir\FedUtils8 %+ endiff
set Menu[1]=%@if[plugin FedUtils8,2)*FedUtils8,2) FedUtils8]
return
::------------------------------------+
:: Option 3 |
::------------------------------------+
:option3
iff plugin SafeChars then plugin /u SafeChars %+ else %+ plugin /l %plugindir\SafeChars %+ endiff
set Menu[2]=%@if[plugin SafeChars,3)*SafeChars,3) SafeChars]
return
You will have to modify the code to reflect the plugins that you use.
In this first example, the asterisk indicates that the FedUtils8 plugin is loaded. To unload the FedUtils8 plugin, simply highlight this row, and press Enter.
1) ISO8601
2)*FedUtils8
3) SafeChars
4) Exit This Menu
In this next example, the asterisk indicates that the ISO8601 and SafeChars plugins are loaded. To unload them, simply use the arrow keys to move the highlight, and press Enter.
1)*ISO8601
2) FedUtils8
3)*SafeChars
4) Exit This Menu
Joe