|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sun Aug 07, 2011 9:52 am
Package toggle? |
Is there a way to toggle weather or not a package is enabled in a given window?
I have been having this setting tend to remain unsaved if the system turns off suddenly, which becomes an issue with lots of packages with buttons in them when shared.
I can think of a workaround, but i need to figure out the toggle.
#EVENT onLoad {
$package="such and such"
$totWin=%numitems(%names)
$thisWin=2
#LOCAL $window
#WHILE ($thisWin!>$totWin) {
$window=%item(%names, %thisWin)
#CALL %pkgState($window, $package, %boolean) //contrived command
$thisWin=($thisWin+1)
}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sun Aug 07, 2011 4:13 pm |
Check out the %packages function. It doesn't do exactly what you want, but you could easily write a user-defined function for a toggle.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sun Aug 07, 2011 8:02 pm |
So... to reset it...
#call %packages( $window, %null)
Alright, I can make that work. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sun Aug 07, 2011 8:45 pm |
You probably wouldn't want %null, though, you just want to remove that one package, not all of them. Try something like #CALL %packages($window,%delitem($package,%packages(%window)).
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sun Aug 07, 2011 8:56 pm |
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<func name="pkgState" copy="yes">
<value>#IF (!$window OR !$package) {
#SAY "Syntax: #CALL @pkgState(window, package, optional 0 or 1)"
#EXIT
}
#IF %null( $boolean) {#IF %ismember( $package, %packages( $window)) {$boolean = 0} {$boolean = 1}}
$packages = %packages( $window)
#IF $boolean {#CALL %packages( $window, %additem( $package, $packages))} {#CALL %packages( $window, %delitem( $package, $packages))}</value>
<arglist>$window,$package,$boolean</arglist>
</func>
</cmud> |
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Dec 17, 2011 7:31 am |
Finally got around to implementing this, and so far this looks like it might work... lets hope it can counteract the windows force closing CMUD issue from another thread.
Code: |
<event event="onLoad" priority="360" id="37">
<value>$list=%names
#CALL %pop($list)
#FORALL $list {#CALL @pkgState(%i, %class, 0)}</value>
</event>
|
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|