mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
What's wrong with this code?

Code:
 on 1:dialog:dialog1:edit:*:{ 
 set %textbox1 $did(1).text 
 if ($did(dialog1,30).state == 0){ /set %var1 $asc($did(40).text) } 
 else { /set %var1 $chr(45) }
} 


Last edited by Dylan666; 07/12/08 01:48 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Nothing that I can see, presuming the following are true:
1) Dialog ID 30 is either a radio button or a check box
2) ID 40 contains a single character.

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
They are both true
The next part of the code is this:

Code:
 on 1:dialog:dialog1:sclick:100:{ 
 var %i = 1
 while (%i <= $did(1).lines) {
 %line= $did(1,%i).text
 %first = $gettok(%line,$did(50).text,%var1)
 %second= $gettok(%line,$did(60).text,%var1)
 inc %i
 /echo -a state $did(dialog1,30).state
 /echo -a data %var1 
 /echo -a text $asc($did(40).text)
 /echo -a first %first 
 /echo -a second %second
 }
}


Ok, let's try:
I write this in the text box:

Code:
cat.dog.mouse.lion


In the ID 40 i write "." (without "")
I read this:

Code:
state 0
data 46
text 46
first cat
second dog


That's ok

Now I click in the checkbox (ID 30) and I write:
Code:
cat-dog-mouse-lion


I read this:

Code:
state 1
data
text
first
second


Why?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I have the feeling that your real problem lies in part of the code that you aren't showing.
If this is true, don't feel bad as it happens to the best of us.

If you would post your full code here, or in a Pastebin and then reference the pastebin here, I should be able to determine if what I suspect is correct, and then be of more assistance.

Please note that I have company coming for the day in a couple of hours, so if you don't get it to me by then, I won't be able to work on it until Monday.

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
This is the entire script. I have isolated this part in a dedicated test.ini file, so other script should not interfere

Code:
[script]
 menu status,channel,query {
  ..-
  - T E S T I N G -
  .- Command - : /xtest
 }
;########################### 
 alias xtest { dialog -m dialog1 dialog1 }
 dialog dialog1 {
  title "Test dialog"
  size -1 -1 401 161
  option pixels
  text "List", 2, 7 3 49 12
  edit "", 1, 2 17 221 109, multi return autohs autovs hsbar sbar
  button "OK", 100, 91 133 44 20, ok
  check "TAB", 30, 355 18 50 20
  text "Separator", 4, 235 21 57 16
  edit "", 40, 300 18 48 21
  text "First element", 5, 235 55 75 16
  edit "", 50, 340 49 48 21
  text "Second element", 6, 235 89 103 16
  edit "", 60, 340 83 48 21
}
 on 1:dialog:dialog1:sclick:30:{
 if ($did(dialog1,30).state == 1) { /did -m dialog1 40 } 
 else { /did -n dialog1 40 } 
}
 on 1:dialog:dialog1:edit:*:{ 
 if ($did(dialog1,30).state == 0){ /set %var1 asc($did(40).text) }
 else { /set %var1 $chr(45) }
} 
 on 1:dialog:dialog1:sclick:100:{ 
 var %i = 1
 while (%i <= $did(1).lines) {
 %line = $did(1,%i).text
 %first = $gettok(%line,$did(50).text,%var1)
 %second = $gettok(%line,$did(60).text,%var1)
 inc %i
 /echo -a state $did(dialog1,30).state
 /echo -a data %var1 
 /echo -a text $asc($did(40).text)
 /echo -a first %first
 /echo -a second %second
 }
}

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
Did you see something wrong?

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
if ($did(dialog1,30).state == 0){ /set %var1 $asc($did(40).text) }


No space between comparison and opening bracket. Im surprised you didnt get a bracket mismatch errror. Or do you not check for those?

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
ok, spaces added
Another error was here:

Code:
else { /set %var1 $chr(45) }



I should have used $asc(-)

Last edited by Dylan666; 13/12/08 02:35 PM.

Link Copied to Clipboard