GUS / FBS AND PSYSCRIPT PEOPLE CAN USE THIS
/*
** NOTE:
**
** The following alias adds, replaces or removes
** a command and its admin level in cmd.ini,
** keeping the levels in numerical sequence.
** Syntax:
** SetCommandLevel <NewCmd> <NewCmdLvl>
** Examples:
** SetCommandLevel !givecash 5 ; Add or Replace
** SetCommandLevel !givecash DEL ; Delete
*/
alias SetCommandLevel {
var %NewCmd = $1, %NewCmdLvl = $2
var %file = cmd.ini, %section = COMMANDS
; Creat Hidden Window
window -h @cmds
var %a = 1, %b = 2, %c = 1, %t
; Total Commands
%t = $ini(%file,%section,0)
; Hold %file in buffer
while (%a <= %t) { echo @cmds $ini(%file,%section,%a) $readini(%file,%section,$ini(%file,%section,%a)) | inc %a }
; Insert, Replace or remove
; New-Command to buffer
if ($2 isnum) {
$iif( $fline(@cmds,$+(*,%NewCmd,*),1), !rline @cmds $fline(@cmds,$+(*,%NewCmd,*),1) %NewCmd %NewCmdLvl, !aline @cmds %NewCmd %NewCmdLvl )
}
elseif ($2 == DEL) { dline @cmds $fline(@cmds,$+(*,%NewCmd,*),1) }
; Remove original section/values
!remini %file %section
; Readd Section
!write -il1 %file $+([,%section,])
; Sort by level
filter -wwcut 2 32 @cmds @cmds
; Loop through buffer and write back contents
while $line(@cmds,%c) { var %cmd = $gettok($v1,1,32), %lvl = $gettok($v1,2,32) | !write -il $+ %b %file $+(%cmd,=,%lvl) | !inc %b | !inc %c }
; Close window
window -c @cmds
}