mIRC Home    About    Download    Register    News    Help

Print Thread
#142016 15/02/06 02:26 AM
Joined: Feb 2006
Posts: 3
D
Devik Offline OP
Self-satisified door
OP Offline
Self-satisified door
D
Joined: Feb 2006
Posts: 3
Hey folks,

im working on my own toolbar script to optimize my mirc usability. But i have some problems which i dont understand.
When i run mirc from a directory like C:\Mircscript\ the Toolbar/Scripts works without any problems but when I move it to C:\Program Files\My Mircscript\ it completely fails to load.
I think its a problem with some pathname-variables cause mirc echoes a pathname like C:\Program (thats the end) and fails to load.

I dont know what's the problem cause im really new in Mircscript.
If you have any ideas which can help, please tell me about.


This is the script:

Code:
;Events

on *:load: {
  if ($version < 6.03) { 
    echo -a Es wird mindestens mIRC 6.16 benötigt.
    .unload -rs ctbar.mrc 
  }
  else {
    echo -a Toolbar-Addon gestartet. Tippe /tbarsetup um es zu konfigurieren.
  }
}

on *:start: {
  if ($rconf(Toolbar) = on) { 
    dialog -m tb tb
    $iif($rconf(Rambar) = on,.timerram 0 $iif($rconf(ramcheck),$ifmatch,10) did -ra tb 6 $round($remove($gettok($dll($moo,meminfo,_),3,32),$chr(40),$chr(41),$chr(37)),0))
  }
}

on *:connect: {
  update.tb
  .timerlag 0 $iif($rconf(Lagcheck),$ifmatch,10) tlag
}

on *:disconnect: {
  update.tb
  .timerlag off
}

on *:active:*: {
  update.tb
}

on *:close:*: {
  update.tb
}

on ^*:PONG:{ 
  set %lag $calc(($ticks - %ticks) / 1000) 
  if ($dialog(tb) && $rconf(Lagbar) = on) {
    did -ra tb 3 $round(%lag,0) 0 20
  }
  unset %ticks 
  haltdef 
}

;Aliases

alias mdx { dll $shortfn($mircdiraddons\Toolbar\mdx.dll) $$1- }
alias rebar { dll $shortfn($mircdiraddons\Toolbar\rebar.dll) $$1- }
alias bars { return $shortfn($mircdiraddons\Toolbar\bars.mdx) }
alias ctl { return $shortfn($mircdiraddons\Toolbar\ctl_gen.mdx) } 
alias views { return $shortfn($mircdiraddons\Toolbar\views.mdx) }
alias conf { writeini $shortfn($mircdiraddons\Toolbar\Toolbar.ini) Settings $1 $2- }
alias rconf { return $readini($shortfn($mircdiraddons\Toolbar\Toolbar.ini),Settings,$1) }
alias tbarsetup { $iif(!$dialog(tbarsetup),dialog -m tbarsetup tbarsetup,dialog -v tbarsetup) }

alias pop1 { 
  tokenize 32 $dll($shortfn($mircdiraddons\Toolbar\popups.dll),Popup,$1-) 
  if ($isid) return $1- 
  $iif($4- != did not select a menu item,$4-)
}

alias tlag { 
  if ($server) {
    set %ticks $ticks
    .raw ping $scid($activecid).server
  }
}

alias tbar.pop {
  popups New server 16 16
  popups SetMetrics server iconpad 10 0 contentpad 0 0 spacing 1 0
  var %l = 1 
  while (%l <= $lines($shortfn($mircdiraddons\Toolbar\Servers.dat))) { 
    var %port = $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),2,42)
    popups AddItem server end + $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),1,42) $cr server $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),1,42) %port
    inc %l 
  } 
  popups AddItem server end +
  popups AddItem server end +> Neue Verbindung $cr newcon
  popups New newcon 16 16
  popups SetMetrics newcon iconpad 10 0 contentpad 0 0 spacing 1 0
  var %l = 1 
  while (%l <= $lines($shortfn($mircdiraddons\Toolbar\Servers.dat))) { 
    var %port = $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),2,42)
    popups AddItem newcon end + $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),1,42) $cr server -m $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%l),1,42) %port 
    inc %l 
  }
  pop1 server $mouse.dx $mouse.dy
}

alias update.tb {
  if (!$dialog(tb)) { halt }
  else {
    scid $activecid
    if ( $scid($activecid).status = connecting || $scid($activecid).status = connected ) { 
      did -o tb 1 2 +v 2 $chr(9) $+ Disconnect 
      mdx MoveControl tb 1 $iif($rconf(Lagbar) = on,100,$iif($rconf(Rambar) = on,100,4)) 4 3500 2 
      $iif($rconf(Lagbar) = on,mdx MoveControl tb 5 4 3 17 12)
      $iif($rconf(Rambar) = on,mdx MoveControl tb 4 4 16 17 12)
      $iif($rconf(Lagbar) = on,mdx MoveControl tb 3 20 7 60 7)
      $iif($rconf(Rambar) = on,mdx MoveControl tb 6 20 20 60 7)   
    }
    else {
      did -o tb 1 2 +v 1 $chr(9) $+ Connect 
      mdx MoveControl tb 1 $iif($rconf(Lagbar) = on,100,$iif($rconf(Rambar) = on,100,4)) 4 3500 2 
      $iif($rconf(Lagbar) = on,mdx MoveControl tb 5 4 3 17 12)
      $iif($rconf(Rambar) = on,mdx MoveControl tb 4 4 16 17 12)
      $iif($rconf(Lagbar) = on,mdx MoveControl tb 3 20 7 60 7)
      $iif($rconf(Rambar) = on,mdx MoveControl tb 6 20 20 60 7)
    }
  }
}

alias -l load_tb.data {
  var %tb = 1
  var %seps = 0
  while (%tb <= $lines($shortfn($mircdiraddons\Toolbar\Data.dat))) {
    if ($read($shortfn($mircdiraddons\Toolbar\Data.dat),%tb) != -) {
      did -i $dname 2 1 seticon normal $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%tb),1,42)
      inc %tb
    } 
    else { inc %tb | inc %seps }
  }
  var %tb = 1
  var %seps = 0
  while (%tb <= $lines($shortfn($mircdiraddons\Toolbar\Data.dat))) {
    if ($read($shortfn($mircdiraddons\Toolbar\Data.dat),%tb) != - ) {
      did -i $dname 2 1 seticon normal $gettok($read($_dat(tb),%tb),1,42)
      did -a $dname 2 +br $calc(%tb - %seps) $calc(%tb - %seps)  $chr(9) $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%tb),2,42) $chr(9) $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%tb),3,42) 
      inc %tb
    }
    else {
      did -a $dname 2 - $chr(9) $+ Separator $chr(9) $+ -
      inc %tb
      inc %seps
    }
  }
}

alias -l load_servers {
  var %i = 1 
  while (%i <= $lines($shortfn($mircdiraddons\Toolbar\Servers.dat))) {
    did -a $dname 26 $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%i),1,42) $chr(9) $gettok($read($shortfn($mircdiraddons\Toolbar\Servers.dat),%i),2,42)
    inc %i
  }
}

;Dialog tables

dialog tb {
  title "failure"
  size 0 0 518 3
  option dbu
  list 1, 2 2 2978 20, size
  box "", 2, -4 -3 3000 19
  text "", 6, 191 43 41 4
  text "L:", 5, 173 43 10 4, disable
  text "", 3, 191 48 41 4
  text "R:", 4, 173 48 10 4, disable
}

on *:dialog:tb:init:0: {
  if ($rconf(Lagbar) = off) { did -h $dname 5,3 }
  if ($rconf(Rambar) = off) { did -h $dname 4,6 }
  set %seps 0
  mdx MarkDialog $dname
  mdx SetControlMDX $dname 1 Toolbar flat arrows nodivider wrap > $bars
  mdx SetControlMDX $dname 3,6 Progressbar smooth > $ctl
  mdx SetFont $dname 4,5 -10 700 Arial
  mdx SetDialog $dname style 
  mdx SetBorderStyle $dname 1
  if ($rconf(XPbkg) = on) {
    mdx SetDialog $dname bgcolor $rgb(222,220,213) 
    mdx SetColor $dname 1,4,5 background $rgb(222,220,213) 
    mdx SetColor $dname 4,5 textbg $rgb(222,220,213)
  }
  if ($rconf(XPscheme) = on) {
    did -i $dname 1 1 setscheme $rgb(163,163,163) $rgb(163,163,163)
  }
  did -i $dname 1 1 bmpsize 24 24
  did -i $dname 1 1 setimage icon large $shortfn($mircdiraddons\Toolbar\Connect.ico)
  did -i $dname 1 1 setimage icon large $shortfn($mircdiraddons\Toolbar\Disconnect.ico)
  var %t = 1
  while (%t <= $lines($shortfn($mircdiraddons\Toolbar\Data.dat))) {
    if ($read($shortfn($mircdiraddons\Toolbar\Data.dat),%t) = -) { inc %t }
    var %icon = $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%t),1,42)
    did -i $dname 1 1 setimage icon large %icon
    inc %t
  }
  did -a $dname 1 +v 1 $chr(9) $+ Connect
  did -a $dname 1 -
  var %r = 1
  while (%r <= $lines($shortfn($mircdiraddons\Toolbar\Data.dat))) {
    if ($read($shortfn($mircdiraddons\Toolbar\Data.dat),%r) != -) {
      did -a $dname 1 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%r),4,42) $calc(%r + 2 - %seps) $chr(9) $+ $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%r),2,42)
      inc %r
    } 
    else { did -a $dname 1 - | inc %r | inc %seps }
  }
  update.tb
  rebar HideToolbar .
  rebar Dock $dialog(tb).hwnd > top
}

on *:dialog:tb:sclick:1: {
  if ($did($dname,1).sel = 2) {
    if ($scid($activecid).status = connecting || $scid($activecid).status = connected ) { scid $activecid disconnect }
    else {
      scid $activecid server
    }
    update.tb
    did -f $dname 2
    scid $activecid window -a "status window"
  }
  else {
    var %sel $calc($did($dname,1).sel - 3)
    .timercmd -m 1 1 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),3,42)
  }
}

on *:dialog:tb:dclick:1: {
  if ($did($dname,1).sel = 2) {
    tbar.pop
  }
  else {
    var %sel $calc($did($dname,1).sel - 3)
    .timercmd -m 1 1 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),5,42)
  }
}

dialog icon {
  title "Select Icon..."
  size -1 -1 168 110
  option dbu
  icon $icl, 12
  list 1, 1 3 166 94, size
  edit "", 2, 0 99 151 10, read autohs
  button "!", 3, 153 99 14 10
}

on *:dialog:icon:init:0: {
  mdx MarkDialog $dname
  mdx SetControlMDX $dname 1 Listview large icon single showsel > $views
  mdx SetDialog $dname icon
  mdx SetFont $dname 1,2,3 -11 400 Arial
  var %p = %icl_,%i = 0,%x = $dll($shortfn($mircdiraddons\Toolbar\ktools.dll),CountIcons,%icl_)
  .did -ra icon 2 Total Icons: $remove(%x,$chr(32),$true) - File: $nopath(%p)
  if (%x == 0) { .did -ra icon 2 Invalid Icon File: $nopath(%p) | return }
  .did -r icon 1 | .did -i icon 1 1 clearicons normal
  %~32 = $+(%x,$chr(171),$nopath(%p))
  while (%i <= %x) {
    .did -i icon 1 1 seticon large 0 $+(%i,$chr(44),%p)
    if (%i != 0) { .did -a icon 1 0 + %i 0 0 $calc(%i -1) }
    inc %i
  }
}

on *:dialog:icon:sclick:1: { set %icl_sel $calc($did($dname,1).sel -2) }

on *:dialog:icon:sclick:3: {
  set %icl_icon %icl_sel $+ , $+ %icl_
  did -ra tbarsetup 4 %icl_icon 
  unset %icl_icon
  unset %icl_sel
  unset %icl_
  dialog -x $dname
}

on *:dialog:tbarsetup:init:0: {
  mdx MarkDialog $dname
  mdx SetControlMDX $dname 2,26 Listview report rowselect single > $views
  mdx SetDialog $dname icon
  mdx SetFont $dname 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,33 -11 400 Arial
  did -i $dname 2 1 headerdims 50 140 150
  did -i $dname 2 1 headertext Icon $chr(9) Caption $chr(9) Command
  did -i $dname 26 1 headerdims 230 71
  did -i $dname 26 1 headertext Server address $chr(9) Port

  $iif($rconf(Toolbar) = on,did -c $dname 12)
  $iif($rconf(XPbkg) = on,did -c $dname 15)
  $iif($rconf(XPscheme) = on,did -c $dname 16)
  $iif($rconf(Lagbar) = on,did -c $dname 17)
  $iif($rconf(Rambar) = on,did -c $dname 21)
  $iif($rconf(Lagcheck),did -ra $dname 19 $ifmatch)
  $iif($rconf(Ramcheck),did -ra $dname 23 $ifmatch)
  did -c $dname 4,7,9,19,23,30,32 1
  load_tb.data
  load_servers
}

on *:dialog:tbarsetup:sclick:2: {
  if ($did($dname,2).sel) {
    var %sel = $calc($did($dname,2).sel - 1)
    did -ra $dname 4 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),1,42)
    did -ra $dname 7 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),2,42)
    did -ra $dname 9 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),3,42)
    did -ra $dname 30 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),4,42)
    did -ra $dname 32 $gettok($read($shortfn($mircdiraddons\Toolbar\Data.dat),%sel),5,42)
    did -c $dname 4,7,9,19,23,30,32
  }
  else { did -r $dname 4,7,9,30,32 }
}

on *:dialog:tbarsetup:sclick:5: {
  var %i = $sfile(C:,Select an icon to use,Select)
  if (%i) {
    if (.icl isin %i || .dll isin %i || .exe isin %i) { set %icl_ %i | dialog -m icon icon }
    else { did -ra $dname 4 %i }
  }
}

on *:dialog:tbarsetup:sclick:10: {
  if ($did($dname,4).text && $did($dname,7).text && $did($dname,9).text) {
    var %icon = $did($dname,4).text
    var %cap = $did($dname,7).text  
    var %cmd = $did($dname,9).text
    write $shortfn($mircdiraddons\Toolbar\Data.dat) %icon $+ * $+ %cap $+ * $+ %cmd $+ * $+ $iif($did($dname,30).text,$did($dname,30).text,+) $+ * $+ $iif($did($dname,32).text,$did($dname,32).text,None)
    did -r $dname 2,4,7,9,30,32
    did -i $dname 2 1 clearicons normal
    load_tb.data
  }
}

on *:dialog:tbarsetup:sclick:11: {
  if ($did($dname,2).sel) {
    var %sel = $calc($did($dname,2).sel - 1)
    write -dl $+ %sel $shortfn($mircdiraddons\Toolbar\Data.dat)
    did -r $dname 2,4,7,9,30,32
    did -i $dname 2 1 clearicons normal
    load_tb.data
  }
}

on *:dialog:tbarsetup:sclick:13: {
  $iif($did($dname,12).state = 1,conf Toolbar on,conf Toolbar off)
  $iif($did($dname,15).state = 1,conf XPbkg on,conf XPbkg off)
  $iif($did($dname,16).state = 1,conf XPscheme on,conf XPscheme off)
  $iif($did($dname,17).state = 1,conf Lagbar on,conf Lagbar off)
  $iif($did($dname,19).text,conf Lagcheck $did($dname,19).text)
  $iif($did($dname,23).text,conf Ramcheck $did($dname,23).text)
  $iif($did($dname,21).state = 1,conf Rambar on,conf Rambar off)

  if ($did($dname,12).state = 1 && !$dialog(tb)) {
    dialog -m tb tb
  }
  elseif ($did($dname,12).state = 0 && $dialog(tb)) {
    dialog -x tb
    rebar UnDock top
    rebar ShowToolbar
  }
  elseif ($did($dname,12).state = 1 && $dialog(tb)) {
    dialog -x tb
    dialog -m tb tb
  } 
  $iif($did($dname,17).state  = 1,.timerlag 0 $iif($rconf(Lagcheck),$ifmatch,10) tlag)
  $iif($did($dname,21).state = 1,.timerram 0 $iif($rconf(ramcheck),$ifmatch,10) $iif($dialog(tb),did -ra tb 6 $round($remove($gettok($dll($moo,meminfo,_),3,32),$chr(40),$chr(41),$chr(37)),0)))
  $iif($did($dname,17).state = 0,$iif($timer(lag),.timerlag off))
  $iif($did($dname,21).state = 0,$iif($timer(ram),.timerram off))
}

on *:dialog:tbarsetup:sclick:27: {
  var %server = $$?="Enter server address:"
  var %port = $$?="Enter port number:"
  if (%server && %port) {
    write $shortfn($mircdiraddons\Toolbar\Servers.dat) %server $+ * $+ %port
    did -r $dname 26
    load_servers
  }
}

on *:dialog:tbarsetup:sclick:28: {
  if ($did($dname,26).sel) {
    var %sel = $calc($did($dname,26).sel - 1)
    write -dl $+ %sel $shortfn($mircdiraddons\Toolbar\Servers.dat)
    did -r $dname 26
    load_servers
  }
}

on *:dialog:tbarsetup:sclick:33: {
  write $shortfn($mircdiraddons\Toolbar\Data.dat) -
  did -r $dname 2 
  did -i $dname 2 1 clearicons normal
  load_tb.data
}

;Menubar popup

menu menubar {
  Toolbar
  ..$iif($rconf(Toolbar) = on,$style(1)) $+ anzeigen:toolbar on
  ..$iif($rconf(Toolbar) = off,$style(1)) $+ verstecken:toolbar off
}

alias toolbar { 
  if ($1 = on && !$dialog(tb)) {
    dialog -m tb tb
    conf Toolbar on
  }
  elseif ($1 = off && $dialog(tb)) {
    dialog -x tb
    rebar UnDock top
    rebar ShowToolbar
    conf Toolbar off
  }
  elseif ($1 = refresh && $dialog(tb)) {
    dialog -x tb
    dialog -m tb tb
  }
}




There is also a small screenshot:




greetings,
Devik

Last edited by Devik; 15/02/06 02:56 AM.
#142017 15/02/06 09:37 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You're using $shortfn everywhere so I can't really see why you'd get an error.

If you can narrow that script down a bit to where you think the error is people will be more willing to help you.

#142018 15/02/06 04:17 PM
Joined: Feb 2006
Posts: 3
D
Devik Offline OP
Self-satisified door
OP Offline
Self-satisified door
D
Joined: Feb 2006
Posts: 3
Ok, I'll try.

My mirc is currently located in C:\new folder\mircscript\
When I run it, it shows a damaged toolbar an this error:

* /dll: unable to open 'C:\new' (line 49, Toolbar.ini)

but on Line 49 is only this code:

Code:
alias mdx { dll $shortfn(addons\Toolbar\mdx.dll) $$1- }
alias rebar { dll $shortfn(addons\Toolbar\rebar.dll) $$1- }
alias bars { return $shortfn(addons\Toolbar\bars.mdx) }
alias ctl { return $shortfn(addons\Toolbar\ctl_gen.mdx) } 
alias views { return $shortfn(addons\Toolbar\views.mdx) }
alias conf { writeini $shortfn(addons\Toolbar\Toolbar.ini) Settings $1 $2- }
alias rconf { return $readini($shortfn(addons\Toolbar\Toolbar.ini),Settings,$1) }
alias tbarsetup { $iif(!$dialog(tbarsetup),dialog -m tbarsetup tbarsetup,dialog -v tbarsetup) }


i dont understand this error, when I change the pathnames to { dll ($mircdiraddons\Toolbar\mdx.dll) $$1- } for example, there are no more errors - but the toolbar won't work. But when I move my mircscript to C:\mircscript\ it works fine?!

#142019 15/02/06 04:49 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
as a wild guess, rename your folder
C:\new folder\mircscript\
to
C:\newfolder\mircscript\

that or go find every filename reference that is going to fail because of the space in the filepath and use a $+(", whatever ,") to repair the line(s)

FEX where you have a $$1- which will hold the path/filename
enclose it with "" like $+(",$$1- ,")

#142020 15/02/06 04:52 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
This is weird. $shortfn shouldn't return a path with any spaces in the name.

Try this instead:

Code:
alias mdx dll " $+ $mircdiraddons\toolbar\mdx.dll" $1-


Same for all of the others.

#142021 15/02/06 05:12 PM
Joined: Feb 2006
Posts: 3
D
Devik Offline OP
Self-satisified door
OP Offline
Self-satisified door
D
Joined: Feb 2006
Posts: 3
yeah! It works now laugh

I changed

alias mdx dll " $+ $mircdiraddons\toolbar\mdx.dll" $1-
alias rebar dll " $+ $mircdiraddons\toolbar\rebar.dll" $1-

and now it works. Thanks for your help!


Link Copied to Clipboard