mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2005
Posts: 9
R
ReK_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
I started this script this morning and got it mostly working. There are two bugs I've found so far. The colour codes don't work properly (the initial character, the one that comes before the colour number, is omitted, messing up the first colour sequence. The second bug is that I cant seem to get the setup dialog working right. It doesn't write the channel names to the ini file and it always sets numchans to 0. It also doesn't remember the joinchans variable, keeping it zero. The other variable seem to be fine.

I've been staring at this all day and my eyes are tired. It's probably something simple, but I can't see it for the life of me. Could someone take a look at it please?

By the way, I know it has some roundabout code in there, but I couldn't get the $var[$+ %var2] array system to work, so I had to copy/paste a whole bunch of ifs. How are you supposed to use it?
Code:
 
;********************
;*Setup dialog table*
;********************

dialog scad_setup_t {
  title "Scrim Advertisment 1.0 Setup"
  size -1 -1 127 130
  option dbu
  tab "Channels", 1, 0 0 126 130
  check "1:", 11, 4 17 16 10, tab 1 left
  check "2:", 12, 4 28 16 10, tab 1 left
  check "3:", 13, 4 39 16 10, tab 1 left
  check "4:", 14, 4 50 16 10, tab 1 left
  check "5:", 15, 4 61 16 10, tab 1 left
  check "6:", 16, 4 72 16 10, tab 1 left
  check "7:", 17, 4 83 16 10, tab 1 left
  check "8:", 18, 4 94 16 10, tab 1 left
  check "9:", 19, 4 105 16 10, tab 1 left
  check "10:", 110, 2 116 18 10, tab 1 left
  edit "", 111, 24 17 72 10, tab 1 autohs limit 255
  edit "", 112, 24 28 72 10, tab 1 autohs limit 255
  edit "", 113, 24 39 72 10, tab 1 autohs limit 255
  edit "", 114, 24 50 72 10, tab 1 autohs limit 255
  edit "", 115, 24 61 72 10, tab 1 autohs limit 255
  edit "", 116, 24 72 72 10, tab 1 autohs limit 255
  edit "", 117, 24 83 72 10, tab 1 autohs limit 255
  edit "", 118, 24 94 72 10, tab 1 autohs limit 255
  edit "", 119, 24 105 72 10, tab 1 autohs limit 255
  edit "", 1110, 24 116 72 10, tab 1 autohs limit 255
  tab "Theme", 2
  text "Insert your theme here. Note that the last colours of the left and middle theme sections should be the colours you want the text to be.", 20, 4 20 118 20, tab 2
  text "Left:", 21, 9 44 12 8, tab 2 right
  text "Middle:", 23, 4 56 17 8, tab 2 right
  text "Right:", 25, 6 68 15 8, tab 2 right
  edit "", 22, 25 43 97 10, tab 2
  edit "", 26, 25 68 97 10, tab 2
  edit "", 24, 25 55 97 10, tab 2
  tab "Messages", 3
  text "Clan Acronym:", 30, 4 17 35 8, tab 3
  text "Match size:", 32, 4 39 27 8, tab 3
  text "Server:", 34, 4 83 18 8, tab 3
  text "Map:", 36, 4 61 12 8, tab 3
  text "Contact info:", 38, 4 105 32 8, tab 3
  edit "", 31, 4 26 118 10, tab 3
  edit "", 33, 4 48 118 10, tab 3
  edit "", 35, 3 70 118 10, tab 3
  edit "", 37, 4 92 118 10, tab 3
  edit "", 39, 4 114 92 10, tab 3
  tab "Other", 4
  check "Join channels as they are messaged", 60, 4 17 98 10, tab 4
  button "Ok", 5, 100 114 22 12, ok
}

;************************
;*Read INI file on start*
;************************

alias readsettings {
  set %joinchans $readini scad.ini general joinchans

  set %numchans $readini scad.ini channels numchans
  set %chan1 $readini scad.ini channels chan1
  set %chan2 $readini scad.ini channels chan2
  set %chan3 $readini scad.ini channels chan3
  set %chan4 $readini scad.ini channels chan4
  set %chan5 $readini scad.ini channels chan5
  set %chan6 $readini scad.ini channels chan6
  set %chan7 $readini scad.ini channels chan7
  set %chan8 $readini scad.ini channels chan8
  set %chan9 $readini scad.ini channels chan9
  set %chan10 $readini scad.ini channels chan10

  set %tl $readini scad.ini theme left
  set %tm $readini scad.ini theme mid
  set %tr $readini scad.ini theme right

  set %name $readini scad.ini info name
  set %size $readini scad.ini info size
  set %map $readini scad.ini info map
  set %serv $readini scad.ini info serv
  set %info $readini scad.ini info info
  set %slook $readini scad.ini info slook
  set %sfind $readini scad.ini info sfind
  set %rlook $readini scad.ini info rlook
  set %rfind $readini scad.ini info rfind
  set %ram $readini scad.ini info ram
  set %pmme $readini scad.ini info pmme

  set %smessage $readini scad.ini messages smessage
  set %sumessage $readini scad.ini messages sumessage
  set %rmessage $readini scad.ini messages rmessage
  set %rumessage $readini scad.ini messages rumessage
  set %ramessage $readini scad.ini messages ramessage
}
alias startsetup {
  readsettings
  /dialog -m scad_setup scad_setup_t
}
on *:LOAD: {
  /echo 4 Scrim Advertisement Script v1.0 By ReK_
  startsetup
}
on *:START: {
  readsettings
}

;***************
;*Dialog events*
;***************

on *:dialog:scad_setup:init:*: {
  if (%joinchans == 1) /did -c scad_setup 60

  if (%numchans >= 1) {
    /did -c scad_setup 11
    /did -a scad_setup 111 %chan1
  }
  if (%numchans >= 2) {
      /did -c scad_setup 12
      /did -a scad_setup 112 %chan2
  }
  if (%numchans >= 3) {
        /did -c scad_setup 13
        /did -a scad_setup 113 %chan3
  }
  if (%numchans >= 4) {
        /did -c scad_setup 14
        /did -a scad_setup 114 %chan4
  }
  if (%numchans >= 5) {
        /did -c scad_setup 15
        /did -a scad_setup 115 %chan5
  }
  if (%numchans >= 6) {
        /did -c scad_setup 16
        /did -a scad_setup 116 %chan6
  }
  if (%numchans >= 7) {
        /did -c scad_setup 17
        /did -a scad_setup 117 %chan7
  }
  if (%numchans >= 8) {
        /did -c scad_setup 18
        /did -a scad_setup 118 %chan8
  }
  if (%numchans >= 9) {
        /did -c scad_setup 19
        /did -a scad_setup 119 %chan9
  }
  if (%numchans >= 10) {
        /did -c scad_setup 110
        /did -a scad_setup 1110 %chan10
  }
  
  /did -a scad_setup 22 %tl
  /did -a scad_setup 24 %tm
  /did -a scad_setup 26 %tr

  /did -a scad_setup 31 %name
  /did -a scad_setup 33 %size
  /did -a scad_setup 35 %map
  /did -a scad_setup 37 %serv
  /did -a scad_setup 39 %info
}

on *:dialog:scad_setup:sclick:*: {
  /writeini -n scad.ini general joinchans $did(60)

  set %c 0
  if ($did(11) == 1) {
    inc %c
    /writeini -n scad.ini channels chan1 $did(111)
  }
  if ($did(12) == 1) {
    inc %c
    /writeini -n scad.ini channels chan2 $did(112)
  }
  if ($did(13) == 1) {
    inc %c
    /writeini -n scad.ini channels chan3 $did(113)
  }
  if ($did(14) == 1) {
    inc %c
    /writeini -n scad.ini channels chan4 $did(114)
  }
  if ($did(15) == 1) {
    inc %c
    /writeini -n scad.ini channels chan5 $did(115)
  }
  if ($did(16) == 1) {
    inc %c
    /writeini -n scad.ini channels chan6 $did(116)
  }
  if ($did(17) == 1) {
    inc %c
    /writeini -n scad.ini channels chan7 $did(117)
  }
  if ($did(18) == 1) {
    inc %c
    /writeini -n scad.ini channels chan8 $did(118)
  }
  if ($did(19) == 1) {
    inc %c
    /writeini -n scad.ini channels chan9 $did(119)
  }
  if ($did(110) == 1) {
    inc %c
    /writeini -n scad.ini channels chan10 $did(1110)
  }
  /writeini -n scad.ini channels numchans %c

  /writeini -n scad.ini theme left $did(22)
  /writeini -n scad.ini theme mid $did(24)
  /writeini -n scad.ini theme right $did(26)

  /writeini -n scad.ini info name $did(31)
  /writeini -n scad.ini info size $did(33)
  /writeini -n scad.ini info map $did(35)
  /writeini -n scad.ini info serv $did(37)
  /writeini -n scad.ini info info $did(39)

  readsettings
} 


"So long and thanks for all the fish"
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
real quickly I would try using $readini(file.ini,topic,item)
not "$readini scad.ini general joinchans" as you have it now
/help $readini
and I know it is faster to set vars, but why have an ini all set up if you are just going to use /SET global vars? If your script needs the info once while its running or rarely, then use the ini file to keep the data and dont store it in active ram by setting it as well, this would apply to using hash tables they are great for storage and fast retrieval but if you dont need the speed why have it in ram?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, here's a cleaned up version... You had various errors:

Code:
;********************
;*Setup dialog table*
;********************

dialog scad_setup_t {
  title "Scrim Advertisment 1.0 Setup"
  size -1 -1 127 130
  option dbu
  tab "Channels", 1, 0 0 126 130
  check "1:", 11, 4 17 16 10, tab 1 left
  check "2:", 12, 4 28 16 10, tab 1 left
  check "3:", 13, 4 39 16 10, tab 1 left
  check "4:", 14, 4 50 16 10, tab 1 left
  check "5:", 15, 4 61 16 10, tab 1 left
  check "6:", 16, 4 72 16 10, tab 1 left
  check "7:", 17, 4 83 16 10, tab 1 left
  check "8:", 18, 4 94 16 10, tab 1 left
  check "9:", 19, 4 105 16 10, tab 1 left
  check "10:", 110, 2 116 18 10, tab 1 left
  edit "", 111, 24 17 72 10, tab 1 autohs limit 255
  edit "", 112, 24 28 72 10, tab 1 autohs limit 255
  edit "", 113, 24 39 72 10, tab 1 autohs limit 255
  edit "", 114, 24 50 72 10, tab 1 autohs limit 255
  edit "", 115, 24 61 72 10, tab 1 autohs limit 255
  edit "", 116, 24 72 72 10, tab 1 autohs limit 255
  edit "", 117, 24 83 72 10, tab 1 autohs limit 255
  edit "", 118, 24 94 72 10, tab 1 autohs limit 255
  edit "", 119, 24 105 72 10, tab 1 autohs limit 255
  edit "", 1110, 24 116 72 10, tab 1 autohs limit 255
  tab "Theme", 2
  text "Insert your theme here. Note that the last colours of the left and middle theme sections should be the colours you want the text to be.", 20, 4 20 118 20, tab 2
  text "Left:", 21, 9 44 12 8, tab 2 right
  text "Middle:", 23, 4 56 17 8, tab 2 right
  text "Right:", 25, 6 68 15 8, tab 2 right
  edit "", 22, 25 43 97 10, tab 2
  edit "", 26, 25 68 97 10, tab 2
  edit "", 24, 25 55 97 10, tab 2
  tab "Messages", 3
  text "Clan Acronym:", 30, 4 17 35 8, tab 3
  text "Match size:", 32, 4 39 27 8, tab 3
  text "Server:", 34, 4 83 18 8, tab 3
  text "Map:", 36, 4 61 12 8, tab 3
  text "Contact info:", 38, 4 105 32 8, tab 3
  edit "", 31, 4 26 118 10, tab 3
  edit "", 33, 4 48 118 10, tab 3
  edit "", 35, 3 70 118 10, tab 3
  edit "", 37, 4 92 118 10, tab 3
  edit "", 39, 4 114 92 10, tab 3
  tab "Other", 4
  check "Join channels as they are messaged", 60, 4 17 98 10, tab 4
  button "Ok", 5, 100 114 22 12, ok
}

;************************
;*Read INI file on start*
;************************

alias readsettings {
  set %joinchans $readini scad.ini general joinchans

  set %numchans $readini scad.ini channels numchans
  set %chan1 $readini scad.ini channels chan1
  set %chan2 $readini scad.ini channels chan2
  set %chan3 $readini scad.ini channels chan3
  set %chan4 $readini scad.ini channels chan4
  set %chan5 $readini scad.ini channels chan5
  set %chan6 $readini scad.ini channels chan6
  set %chan7 $readini scad.ini channels chan7
  set %chan8 $readini scad.ini channels chan8
  set %chan9 $readini scad.ini channels chan9
  set %chan10 $readini scad.ini channels chan10

  set %tl $replace($readini(scad.ini,theme,left),~c,,~b,,~u,,~o,)
  set %tm $replace($readini(scad.ini,theme,mid),~c,,~b,,~u,,~o,)
  set %tr $replace($readini(scad.ini,theme,right),~c,,~b,,~u,,~o,)

  set %name $readini scad.ini info name
  set %size $readini scad.ini info size
  set %map $readini scad.ini info map
  set %serv $readini scad.ini info serv
  set %info $readini scad.ini info info
  set %slook $readini scad.ini info slook
  set %sfind $readini scad.ini info sfind
  set %rlook $readini scad.ini info rlook
  set %rfind $readini scad.ini info rfind
  set %ram $readini scad.ini info ram
  set %pmme $readini scad.ini info pmme

  set %smessage $readini scad.ini messages smessage
  set %sumessage $readini scad.ini messages sumessage
  set %rmessage $readini scad.ini messages rmessage
  set %rumessage $readini scad.ini messages rumessage
  set %ramessage $readini scad.ini messages ramessage
}
alias startsetup {
  readsettings
  /dialog -m scad_setup scad_setup_t
}
on *:LOAD: {
  /echo 4 Scrim Advertisement Script v1.0 By ReK_
  startsetup
}
on *:START: {
  readsettings
}

;***************
;*Dialog events*
;***************

on *:dialog:scad_setup:init:*: {
  if (%joinchans == 1) /did -c scad_setup 60

  var %cnt 1
  while (%cnt <= %numchans) {
    var %cnt2 %cnt
    while (%cnt2 <= 10) {
      if (%chan [ $+ [ %cnt2 ] ] != $null) {
        did -c scad_setup 1 $+ %cnt
        did -a scad_setup 11 $+ %cnt %chan [ $+ [ %cnt2 ] ]
        break
      }
      inc %cnt2
    }
    inc %cnt
  }

  /did -a scad_setup 22 %tl
  /did -a scad_setup 24 %tm
  /did -a scad_setup 26 %tr

  /did -a scad_setup 31 %name
  /did -a scad_setup 33 %size
  /did -a scad_setup 35 %map
  /did -a scad_setup 37 %serv
  /did -a scad_setup 39 %info
}

on *:dialog:scad_setup:sclick:5: {
  /writeini -n scad.ini general joinchans $did(60)

  remini scad.ini channels
  var %cnt 1
  while (%cnt <= 10) {
    if ($did($calc(10 + %cnt)).state == 1) {
      writeini -n scad.ini channels chan [ $+ [ %cnt ] ] $did(11 $+ %cnt)
    }
    inc %cnt
  }
  set %c $ini(scad.ini,Channels,0)
  /writeini -n scad.ini channels numchans %c

  remini scad.ini theme
  remini scad.ini info
  if ($did(22)) writeini -n scad.ini theme left $replace($did(22),,~c,,~b,,~u,,~o)
  if ($did(24)) writeini -n scad.ini theme mid $replace($did(24),,~c,,~b,,~u,,~o)
  if ($did(26)) writeini -n scad.ini theme right $replace($did(26),,~c,,~b,,~u,,~o)

  if ($did(31)) writeini -n scad.ini info name $did(31)
  if ($did(33)) writeini -n scad.ini info size $did(33)
  if ($did(35)) writeini -n scad.ini info map $did(35)
  if ($did(37)) writeini -n scad.ini info serv $did(37)
  if ($did(39)) writeini -n scad.ini info info $did(39)

  readsettings
} 


Changes are:

.state is needed to see if a checkbox is "1".
Using the while loops shortens the script considerably.
Fixed it so a blank value in theme or info will no longer give an error.
Fixed it so that if someone put a channel in a spot other than in order, it will still work correctly.
Fixed it so that it only writes data when OK is pressed rather than everytime someone single clicks the dialog.
Fixed it so it will remove theme/info data if the person wants to have it blank.

Just a note... the way you have it, if someone unchecks a channel and presses OK, then the channel is removed from the channel list. You may not want it to do that... it's up to you.

And, finally... control codes cannot be placed in an INI file. Therefore, I used replace... replacing the codes with ~k,~c,~b,~o where ~ would be the Ctrl key. You can change this to something else if you think your themes will have a ~ in them for some reason... if so, pick another character that you don't believe would be used.

NOTE: I didn't rewrite or scan your entire code... just what you were having problems with.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I do agree with using $readini in the format of $readini(file,topic,section) rather than $readini file topic section... however, both will work.

As far as variables/inis/hash tables/etc... well, one thing at a time. At least this is working correctly now. laugh


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 9
R
ReK_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
Thanks a lot. As I said, I had first tried it with the arrays, but, looking at how I did it, I used set %cnt, not var %cnt. What's the difference? I had also not used the second pair of brackets in the var name, chan[$+ %cnt].

This is my first time scripting for mIRC, and I had just read the ini commands quickly off a tutorial, it didn't mention using brackets. I think I will though, it would clean up the code a bit.

As for the channels boxes and the checks beside them, I had originally planned to have the check disable the box, but I took it out for the moment as it wasn't working right and I wanted to get the other stuff going first.

Code:
on *:dialog:scad_setup:sclick:11: {
  if($did(11) == 1) /did -n scad_setup 111
  else /did -m scad_setup 111
}


It would disable the editbox when it was checked, and not re-enable it. I realise now it's because of the .state.

I also wouldn't allow the next box to be enabled if there was no channel info in the previous, just hadn't coded it yet. So, thanks for the order-independant system, but I had it covered. No reason not to keep it though.

And I originally had it saving the info only when Ok was clicked, but I got frustrated and turned it to every click. Didn't help, obviously. Just forgot to change it back.

Edit: I should mention that I'm using an ini file basically as a test, I want to get used to them. I'll probably remove it if I ever release this.

Last edited by ReK_; 17/08/05 07:20 PM.

"So long and thanks for all the fish"
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It's always interesting when first starting to script. smile

The differences between var and set is that var will unset itself automatically after the script is completed. It is also only used within that one script. So that if you have 2 scripts with the same variable names, they will not conflict when using var. Set, on the other hand, is for setting a global variable, which will not unset by itself. You should /unset those when they are no longer needed.

If you are using variables that you want to have remain set or you want to use across multiple scripts, then you need to use set instead of var. Remember that you need an = sign with var, whereas you don't need it with set. I actually forgot to add that when doing the script, so you should change any vars in the script above to have an = sign (I can't edit my post and I don't feel like reposting the code).

Example: var %cnt = 1

If you type /help command, you'll get the recommended format for the command. So, /help $readini will give you the section that includes the format for that command... including ()'s and commas. smile

Feel free to add/remove/change my code as needed. I didn't know how you wanted the check boxes to function or that you didn't want a person to even have an option to add channels to any box they could. I just added the code so it would work as it was originally written. If you make a change and need help getting it to work, just ask here and I'll be happy to help more with it.

There isn't anything wrong with using an INI file for settings. Keeping everything as variables isn't always good, and hash tables aren't always the best method, either. It just depends on the script.

*EDIT*
I forgot... The format for adding two items (where at least one is a variable) together would be:

%var1 [ $+ [ %var2 ] ]
chan [ $+ [ %var ] ]

This sets the order of operations. Make sure you have spaces around the []'s. It is not always necessary to use []'s in order to combine the items. It depends what code they are being combined within. It can be useful to just use the []'s all the time if you're unsure where they are needed to prevent forgetting to include them in the correct locations.

Note also, that you can combine items like this instead, if you want:

If:
%var = 100
%var2 = 50
$chan = mirc
$nick = Riamus

Then:
$+(%var,%var2) results in 10050
$+($chan,.,$nick) results in mirc.Riamus
$+(status.,$nick) results in status.Riamus
etc.

Note that by including a . in there, you can help separate the different parts of the final piece. This helps to make things more easily read.

Last edited by Riamus2; 17/08/05 08:22 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 9
R
ReK_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
Thanks, that helps.

I've everything working now except for one last detail. As I said, I wanted the checkboxes to disable the editboxes, and not allow the next editbox to be opened unless the previous has data in it. This is working, but I can't seem to make the edit boxes disable at the start if they have no data. I think this is because of how the %chan [ $+ [ %c ] ] isn't being set to null properly because there is no corresponding variable in the ini file. How can you write a null variable to an ini? Trying $null just returns not enough parameters.

Yes, I've noticed something atypical about mIRC scripting. Unlike C++ and other languages, it seems to actually care about whitespace. It's rather annoying as my usual coding style has very few spaces in it.

Here's the new code, load it up and the dialog will come up. The sequential order works fine, and the disabling does too, they just don't start disabled...

Code:
;********************
;*Setup dialog table*
;********************

dialog scad_setup_t {
  title "Scrim Advertisment 1.0 Setup"
  size -1 -1 128 130
  option dbu
  tab "Channels", 1, 0 0 128 130
  check "1:", 11, 4 17 16 10, tab 1 left
  check "2:", 12, 4 28 16 10, tab 1 left
  check "3:", 13, 4 39 16 10, tab 1 left
  check "4:", 14, 4 50 16 10, tab 1 left
  check "5:", 15, 4 61 16 10, tab 1 left
  check "6:", 16, 4 72 16 10, tab 1 left
  check "7:", 17, 4 83 16 10, tab 1 left
  check "8:", 18, 4 94 16 10, tab 1 left
  check "9:", 19, 4 105 16 10, tab 1 left
  check "10:", 110, 2 116 18 10, tab 1 left
  edit "", 111, 24 17 72 10, tab 1 autohs limit 255
  edit "", 112, 24 28 72 10, tab 1 autohs limit 255
  edit "", 113, 24 39 72 10, tab 1 autohs limit 255
  edit "", 114, 24 50 72 10, tab 1 autohs limit 255
  edit "", 115, 24 61 72 10, tab 1 autohs limit 255
  edit "", 116, 24 72 72 10, tab 1 autohs limit 255
  edit "", 117, 24 83 72 10, tab 1 autohs limit 255
  edit "", 118, 24 94 72 10, tab 1 autohs limit 255
  edit "", 119, 24 105 72 10, tab 1 autohs limit 255
  edit "", 1110, 24 116 72 10, tab 1 autohs limit 255
  tab "Theme", 2
  text "Insert your theme here. Note that the last colours of the left and middle theme sections should be the colours you want the text to be.", 20, 4 20 118 20, tab 2
  text "Left:", 21, 9 44 12 8, tab 2 right
  text "Middle:", 23, 4 56 17 8, tab 2 right
  text "Right:", 25, 6 68 15 8, tab 2 right
  edit "", 22, 25 43 97 10, tab 2
  edit "", 26, 25 68 97 10, tab 2
  edit "", 24, 25 55 97 10, tab 2
  tab "Messages", 3
  text "Clan Acronym:", 30, 4 17 35 8, tab 3
  text "Match size:", 32, 4 39 27 8, tab 3
  text "Server:", 34, 4 83 18 8, tab 3
  text "Map:", 36, 4 61 12 8, tab 3
  text "Contact info:", 38, 4 105 32 8, tab 3
  edit "", 31, 4 26 118 10, tab 3
  edit "", 33, 4 48 118 10, tab 3
  edit "", 35, 3 70 118 10, tab 3
  edit "", 37, 4 92 118 10, tab 3
  edit "", 39, 4 114 92 10, tab 3
  tab "Other", 4
  check "Join channels as they are messaged", 60, 4 17 98 10, tab 4
  button "Ok", 5, 102 114 22 12, ok
}

;************************
;*Read INI file on start*
;************************

alias readsettings {
  set %joinchans $readini(scad.ini,general,joinchans)

  set %numchans $readini(scad.ini,channels,numchans)
  var %c = 1
  while (%c <= %numchans) {
    set %chan [ $+ [ %c ] ] $readini(scad.ini,channels,chan [ $+ [ %c ] ])
    inc %c
  }

  set %tl $replace($readini(scad.ini,theme,left),~c,,~b,,~u,,~o,)
  set %tm $replace($readini(scad.ini,theme,mid),~c,,~b,,~u,,~o,)
  set %tr $replace($readini(scad.ini,theme,right),~c,,~b,,~u,,~o,)

  set %name $readini(scad.ini,info,name)
  set %size $readini(scad.ini,info,size)
  set %map $readini(scad.ini,info,map)
  set %serv $readini(scad.ini,info,serv)
  set %info $readini(scad.ini,info,info)
  set %slook $readini(scad.ini,info,slook)
  set %sfind $readini(scad.ini,info,sfind)
  set %rlook $readini(scad.ini,info,rlook)
  set %rfind $readini(scad.ini,info,rfind)
  set %icanr $readini(scad.ini,info,icanr)
  set %pmme $readini(scad.ini,info,pmme)

  set %smessage $readini(scad.ini,messages,smessage)
  set %sumessage $readini(scad.ini,messages,sumessage)
  set %rmessage $readini(scad.ini,messages,rmessage)
  set %rumessage $readini(scad.ini,messages,rumessage)
  set %ramessage $readini(scad.ini,messages,ramessage)
}
alias startsetup {
  readsettings
  /dialog -m scad_setup scad_setup_t
}
on *:LOAD: {
  /echo 4 Scrim Advertisement Script v1.0 By ReK_
  startsetup
}
on *:START: {
  readsettings
}

;***************
;*Dialog events*
;***************

on *:dialog:scad_setup:init:*: {
  if (%joinchans == 1) /did -c scad_setup 60

  var %c = 1
  while (%c <= %numchans) {
    /did -m scad_setup 11 $+ %c
    if (%chan [ $+ [ %c ] ] != $null) {
        /did -c scad_setup 1 $+ %c
        /did -na scad_setup 11 $+ %c %chan [ $+ [ %c ] ]
    }
    inc %c
  }

  /did -a scad_setup 22 %tl
  /did -a scad_setup 24 %tm
  /did -a scad_setup 26 %tr

  /did -a scad_setup 31 %name
  /did -a scad_setup 33 %size
  /did -a scad_setup 35 %map
  /did -a scad_setup 37 %serv
  /did -a scad_setup 39 %info
}

on *:dialog:scad_setup:sclick:5: {
  /writeini -n scad.ini general joinchans $did(60).state

  writeini -n scad.ini messages smessage %tl %name %slook %tm %size %tm %serv %tm %map %tm %info %tr
  writeini -n scad.ini messages sumessage %tl %sfind %tr
  writeini -n scad.ini messages rmessage %tl %name %rlook %tm %info %tr
  writeini -n scad.ini messages rumessage %tl %rfind %tr
  writeini -n scad.ini messages ramessage %tl %icanr %tm %pmme %tr

  remini scad.ini channels
  var %c = 1
  var %i = 0
  while (%c <= 10) {
    if ($did(scad_setup,1 $+ %c).state == 1 && $did(scad_setup,11 $+ %c) != $null) {
      writeini -n scad.ini channels chan [ $+ [ %c ] ] $did(scad_setup,11 $+ %c)
      inc %i
    }
    elseif ($did(scad_setup,1 $+ %c).state == 0 || $did(scad_setup,11 $+ %c) == $null) {
      ;writeini -n scad.ini channels chan [ $+ [ %c ] ] $null
    }
    inc %c
  }
  /writeini -n scad.ini channels numchans %i

  remini scad.ini theme
  remini scad.ini info
  if ($did(scad_setup,22)) writeini -n scad.ini theme left $replace($did(scad_setup,22),,~c,,~b,,~u,,~o)
  if ($did(scad_setup,24)) writeini -n scad.ini theme mid $replace($did(scad_setup,24),,~c,,~b,,~u,,~o)
  if ($did(scad_setup,26)) writeini -n scad.ini theme right $replace($did(scad_setup,26),,~c,,~b,,~u,,~o)

  if ($did(scad_setup,31)) writeini -n scad.ini info name $did(scad_setup,31)
  if ($did(scad_setup,33)) writeini -n scad.ini info size $did(scad_setup,33)
  if ($did(scad_setup,35)) writeini -n scad.ini info map $did(scad_setup,35)
  if ($did(scad_setup,37)) writeini -n scad.ini info serv $did(scad_setup,37)
  if ($did(scad_setup,39)) writeini -n scad.ini info info $did(scad_setup,39)
  writeini -n scad.ini info slook is looking for a scrim
  writeini -n scad.ini info sfind Scrim found
  writeini -n scad.ini info rlook is looking for a ringer
  writeini -n scad.ini info rfind Ringer found
  writeini -n scad.ini info icanr I can ring
  writeini -n scad.ini info pmme PM me

  readsettings
}

on *:dialog:scad_setup:sclick:11: {
  if ($did(scad_setup,11).state == 1) /did -n scad_setup 111
  else /did -mr scad_setup 111
}
on *:dialog:scad_setup:sclick:12: {
  if ($did(scad_setup,12).state == 1 && $did(111) != $null) /did -n scad_setup 112
  else {
    /did -u scad_setup 12
    /did -mr scad_setup 112
  }
}
on *:dialog:scad_setup:sclick:13: {
  if ($did(scad_setup,13).state == 1 && $did(112) != $null) /did -n scad_setup 113
  else {
    /did -u scad_setup 13
    /did -mr scad_setup 113
  }
}
on *:dialog:scad_setup:sclick:14: {
  if ($did(scad_setup,14).state == 1 && $did(113) != $null) /did -n scad_setup 114
  else {
    /did -u scad_setup 14
    /did -mr scad_setup 114
  }
}
on *:dialog:scad_setup:sclick:15: {
  if ($did(scad_setup,15).state == 1 && $did(114) != $null) /did -n scad_setup 115
  else {
    /did -u scad_setup 15
    /did -mr scad_setup 115
  }
}
on *:dialog:scad_setup:sclick:16: {
  if ($did(scad_setup,16).state == 1 && $did(115) != $null) /did -n scad_setup 116
  else {
    /did -u scad_setup 16
    /did -mr scad_setup 116
  }
}
on *:dialog:scad_setup:sclick:17: {
  if ($did(scad_setup,17).state == 1 && $did(116) != $null) /did -n scad_setup 117
  else {
    /did -u scad_setup 17
    /did -mr scad_setup 117
  }
}
on *:dialog:scad_setup:sclick:18: {
  if ($did(scad_setup,18).state == 1 && $did(117) != $null) /did -n scad_setup 118
  else {
    /did -u scad_setup 18
    /did -mr scad_setup 118
  }
}
on *:dialog:scad_setup:sclick:19: {
  if ($did(scad_setup,19).state == 1 && $did(118) != $null) /did -n scad_setup 119
  else {
    /did -u scad_setup 19
    /did -mr scad_setup 119
  }
}
on *:dialog:scad_setup:sclick:110: {
  if ($did(scad_setup,110).state == 1 && $did(119) != $null) /did -n scad_setup 1110
  else {
    /did -u scad_setup 110
    /did -mr scad_setup 1110
  }
}


"So long and thanks for all the fish"
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
/remini <inifile> <section> [item]
Deletes whole sections or single items in an INI file.

/remini my.ini DDE ServerStatus
This would delete the ServerStatus item.


And yes, mIRC cares about spaces, it's a delimiter. It has advantages (no need to put a ; after each command, no need to put in "" around each string, no need to use & or strconcat or some operator to combine 2 strings, ...
Disadvantages are it being picky about whitespace and not being sure a string keeps a string and isn't evaluated.


For the dialogs, you have to disable them on init iirc, something like
did -b scad_setup 123

You can remove the / and // from your code btw, in script files all lines are considered commands.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Very easy fix. Your loop is from 1 to %numchans.... you need it to loop from 1 to 10 when initializing.

Replace %numchans with 10 in the section below:
Code:
on *:dialog:scad_setup:init:*: {
  if (%joinchans == 1) /did -c scad_setup 60

  var %c = 1
  while (%c &lt;= %numchans) {
    /did -m scad_setup 11 $+ %c
    if (%chan [ $+ [ %c ] ] != $null) {
      /did -c scad_setup 1 $+ %c
      /did -na scad_setup 11 $+ %c %chan [ $+ [ %c ] ]
    }
    inc %c
  }


Btw, I would really recommend looping your sclick sections as I mentioned in the earlier code. Having all those like that is not the best way to code it. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 9
R
ReK_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
I was going to loop them, but how can you loop an on event?

And yes, limiting to %numchans was stupid. I was tired yesterday ok?


"So long and thanks for all the fish"
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You can try this:

Code:
on *:dialog:scad_setup:sclick:*:{
  if ($did == 11) {
    if ($did(scad_setup,11).state == 1) did -n scad_setup 111
    else did -mr scad_setup 111
  }
  elseif ($left($did,1) == 1 &amp;&amp; $right($did,-1) &gt; 0 &amp;&amp; $right($did,-1) &lt; 10) {
      if ($did(scad_setup,$did).state == 1 &amp;&amp; $did(1 $+ $calc($right($did,-1) - 1)) != $null) /did -n scad_setup 1 $+ $did
      else {
        did -u scad_setup $did
        did -mr scad_setup 1 $+ $did
      }
    }
  }
}


Ended up not needing to even loop when I took a moment to look at it. This will handle IDs 11,12,13,14,15,16,17,18,19,110. If you have a question about what this code is doing or whatever, just ask. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 9
R
ReK_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
I assume $did without an id returnsthe id number that called the event?

But what's the $right($did,-1) stuff? What does that return?

Ah, that code doesn't work. It en/disables the edit boxes fine, but it doesn't check to see if the previous has any data.

It also stops the script somehow. The dialog works fine, except for that, but all the code after this event is ignored.

Last edited by ReK_; 19/08/05 09:44 PM.

"So long and thanks for all the fish"
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If your $did is 15, then $right($did,-1) will return 5. If it's 110, it will return 10. This allows us to loop it correctly. from 1 to 10 since you're not using consecutive IDs.

Also, I had to edit the $right($did,-1) < 10 to $right($did,-1) <= 10. Sorry I missed the =. It also seems to have an extra } that I also missed. frown

I also fixed the problem with it not checking to see if the previous box had text. It should work fine now.
Code:
on *:dialog:scad_setup:sclick:*:{
  if ($did == 11) {
    if ($did(scad_setup,11).state == 1) did -n scad_setup 111
    else did -mr scad_setup 111
  }
  elseif ($left($did,1) == 1 &amp;&amp; $right($did,-1) &gt; 0 &amp;&amp; $right($did,-1) &lt;= 10) {
    if ($did(scad_setup,$did).state == 1 &amp;&amp; $did(11 $+ $calc($right($did,-1) - 1)) != $null) /did -n scad_setup 1 $+ $did
    else {
      did -u scad_setup $did
      did -mr scad_setup 1 $+ $did
    }
  }
}


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard