mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#131632 02/10/05 04:12 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
How do I get the information for a drop down box to display in the box?

I have a list of numbers that I want in a drop down box, then when one is selected, it'll bring up other information

I'm trying to learn about dialogs, but the tutorials haven't been of much help in this regard.
I have Dialog Studio, which I'm using to figure out just how I want things laid out on the screen, but I can't figure out how to get the information to display in the appropriate areas.

What I'm looking for, in the long run, is something like this
1) A level is selected
2) Based on the level selected, a list of people that have that access level is displayed
3) Based on the nick selected, the following information will be displayed: Name, Address, Phone #, DOB, Gender, e-mail address

If I can get that much resolved, I should be able to figure out how to add more information if I want to

Right now the information is being stored in an ini file using similar to: /writeini -n $+(%level,.ini) %nick Name %name

#131633 02/10/05 06:55 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
can you post the dialog table so i can insert the script into it please??

because the information you request is something too

Code:
on *:DIALOG:DIALOGNAME:SCLICK:ID: {
if ($did($dname,ID).seltext) { did -ra $dname IDOFLISTBOXHERE $readini(bleh bleh)
}


now of course if theres more then one value in the ini file we have to just insert multiple lines without the list box...

so if im understanding what your requesting exactly is that when you click a nick in your Drop Down menu, you want the INFO of this nick to appear in the dialog Listbox correct like

NAME: name of person
DOB: dob...

etc.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131634 02/10/05 07:15 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Basically, yes. Each person has a Level, so I want one drop box with the levels listed, then another drop box for the names for that level.
Here's the dialog code that I've come up with. I don't know if this may need to be changed for what I actually want.
This shows a basic line up for the information that I want displayed.
I also want to be able to change the information displayed, or be able to add new entries.
Code:
 dialog Observer {
  title Observer
  size -1 -1 440 70
  option dbu
  button "OK", 14, 0 30 20 10, default ok
  text "Level", 15, 0 10 20 8
  combo 16, 20 10 30 8, edit drop
  button "Cancel", 1, 0 50 20 10, cancel
  text "Nick", 2, 60 10 20 8
  combo 3, 80 10 60 48, size edit drop
  text "Name", 4, 150 10 25 8
  edit "", 5, 180 10 50 10
  text "Address", 6, 150 20 25 8
  edit "", 7, 180 20 50 10
  text "Apt.", 8, 240 20 20 8
  edit "", 9, 260 20 20 8
  text "Phone", 10, 150 40 25 8
  edit "", 11, 180 40 50 10
  text "Province/State", 12, 240 30 45 8
  edit "", 13, 280 30 20 8
  text "E-mail", 17, 150 50 25 8
  text "City", 18, 150 30 25 8
  edit "", 19, 180 30 50 10
  edit "", 20, 180 50 50 10
  text "DOB", 21, 240 50 25 8
  edit "", 22, 260 50 40 8
}
 

#131635 02/10/05 09:34 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Well russell since you help alot around mirc.com i mostly coded everything now we can use hash tables to store the info or you can leave as... please insert this code before editing it then when it runs, then edit after. DO NOT use own entries... how this script works
Select Level in drop down trust me theres 4 levels on init. smile
once level is selected type name of person in nick dropdown, then add all the info in (user info) section, then click my new button "store info"

once done close dialog and restart and select the level you put your info in it should be there and then if you drop down nicklist youll see his/her info...

now its not neccasary to restart the dialog you can enter as much info as you want then reselect the Level to store info... smile well im sure youll get the hang of it your not a newb rusell LOL

Code:
dialog Observer {
  title Observer
  size -1 -1 320 0
  option dbu
  button "OK", 14, 5 30 20 10, default ok
  text "Level", 15, 5 10 20 8
  combo 16, 20 10 30 8, edit drop
  button "Cancel", 1, 5 50 20 10, cancel
  text "Nick", 2, 60 10 20 8
  combo 3, 80 10 60 48, size edit drop
  text "Name", 4, 150 10 25 8
  edit "", 5, 180 10 50 10, autohs
  text "Address", 6, 150 20 25 8
  edit "", 7, 180 20 50 10, autohs
  text "Apt.", 8, 240 20 20 8
  edit "", 9, 260 20 20 8, autohs
  text "Phone", 10, 150 40 25 8
  edit "", 11, 180 40 50 10, autohs
  text "Province/State", 12, 240 30 45 8
  edit "", 13, 280 30 20 8, autohs
  text "E-mail", 17, 150 50 25 8
  text "City", 18, 150 30 25 8
  edit "", 19, 180 30 50 10, autohs
  edit "", 20, 180 50 50 10, autohs
  text "DOB", 21, 240 50 25 8
  edit "", 22, 260 50 40 8, autohs left
  button Store New Info, 23, 50 50 50 10, flat

  box User Info, 1000, 145 2 160 62
}

on *:DIALOG:Observer:INIT:*: {
  %resize = on
  if (%resize == on) { .timer 1 0 /diag.size Observer -1 -1 320 70 }
  did -a $dname 16 Level 5
  did -a $dname 16 Level 10
  did -a $dname 16 Level 15
  did -a $dname 16 Level 100
}

on *:DIALOG:Observer:sclick:16: {
  if ($did($dname,16).seltext == Level 5) {
    if ($exists(level5.txt) == $true) {
      var %obs.store = 1, %obs.calc = $lines(level5.txt)
      while (%obs.store <= %obs.calc) {
        did -r $dname 3
        timer 1 0 /did -a $dname 3 $read(level5.txt,%obs.store)
        inc %obs.store
      }
    }
    elseif ($exists(level5.txt) == $false) {
      echo -a 8,1ALERT!!! You have not created a level 5 access doc yet.
    }
  }
  if ($did($dname,16).seltext == Level 10) {
    if ($exists(level10.txt) == $true) {
      var %obs.store = 1, %obs.calc = $lines(level10.txt)
      while (%obs.store <= %obs.calc) {
        did -r $dname 3 
        /timer 1 0 /did -a $dname 3 $read(level10.txt,%obs.store)
        inc %obs.store
      }
    }
    elseif ($exists(level10.txt) == $false) {
      echo -a 8,1ALERT!!!! You have not created a level 10 access doc yet.
    }
  }
  if ($did($dname,16).seltext == Level 15) {
    if ($exists(level15.txt) == $true) {
      var %obs.store = 1, %obs.calc = $lines(level15.txt)
      while (%obs.store <= %obs.calc) {
        did -r $dname 3
        timer 1 0 /did -a $dname 3 $read(level15.txt,%obs.store)
        inc %obs.store
      }
    }
    elseif ($exists(level15.txt) == $false) { 
      echo -a 8,1ALERT!!! You have not created a level 15 access doc yet. 
    }
  }
  if ($did($dname,16).seltext == Level 100) {
    if ($exists(level100.txt) == $true) {
      var %obs.store = 1, %obs.calc = $lines(level100.txt)
      while (%obs.store <= %obs.calc) {
        did -r $dname 3
        timer 1 0 /did -a $dname 3 $read(level100.txt,%obs.store)
        inc %obs.store
      }
    }
    elseif ($exists(level100.txt) == $false) {
      echo -a 8,1ALERT!!! You have not created a level 100 access doc yet.
    }
  }
}

on *:DIALOG:Observer:sclick:3: {
  %name.sel = $did($dname,3).seltext
  did -ra $dname 5 %name.sel
  did -ra $dname 7 $readini(nnames.ini,n,%name.sel,Address)
  did -ra $dname 9 $readini(nnames.ini,n,%name.sel,Apt)
  did -ra $dname 11 $readini(nnames.ini,n,%name.sel,Phone)
  did -ra $dname 13 $readini(nnames.ini,n,%name.sel,prov/state)
  did -ra $dname 19 $readini(nnames.ini,n,%name.sel,City)
  did -ra $dname 20 $readini(nnames.ini,n,%name.sel,email)
  did -ra $dname 22 $readini(nnames.ini,n,%name.sel,DOB)
}

on *:DIALOG:Observer:sclick:23: {
  if ($did($dname,16).seltext == Level 5) {
    write level5.txt $did($dname,3).text
    timer 1 1 writeini nnames.ini $did($dname,3).text Address $did($dname,7).text
    timer 1 2 writeini nnames.ini $did($dname,3).text Apt $did($dname,9).text
    timer 1 3 writeini nnames.ini $did($dname,3).text Phone $did($dname,11).text
    timer 1 4 writeini nnames.ini $did($dname,3).text Prov/State $did($dname,13).text
    timer 1 5 writeini nnames.ini $did($dname,3).text City $did($dname,19).text
    timer 1 6 writeini nnames.ini $did($dname,3).text Email $did($dname,20).text
    timer 1 7 writeini nnames.ini $did($dname,3).text DOB $did($dname,22).text
  }
  if ($did($dname,16).seltext == Level 10) {
    write level10.txt $did($dname,3).text
    timer 1 1 writeini nnames.ini $did($dname,3).text Address $did($dname,7).text
    timer 1 2 writeini nnames.ini $did($dname,3).text Apt $did($dname,9).text
    timer 1 3 writeini nnames.ini $did($dname,3).text Phone $did($dname,11).text
    timer 1 4 writeini nnames.ini $did($dname,3).text Prov/State $did($dname,13).text
    timer 1 5 writeini nnames.ini $did($dname,3).text City $did($dname,19).text
    timer 1 6 writeini nnames.ini $did($dname,3).text Email $did($dname,20).text
    timer 1 7 writeini nnames.ini $did($dname,3).text DOB $did($dname,22).text
  }
  if ($did($dname,16).seltext == Level 15) {
    write level15.txt $did($dname,3).text
    timer 1 1 writeini nnames.ini $did($dname,3).text Address $did($dname,7).text
    timer 1 2 writeini nnames.ini $did($dname,3).text Apt $did($dname,9).text
    timer 1 3 writeini nnames.ini $did($dname,3).text Phone $did($dname,11).text
    timer 1 4 writeini nnames.ini $did($dname,3).text Prov/State $did($dname,13).text
    timer 1 5 writeini nnames.ini $did($dname,3).text City $did($dname,19).text
    timer 1 6 writeini nnames.ini $did($dname,3).text Email $did($dname,20).text
    timer 1 7 writeini nnames.ini $did($dname,3).text DOB $did($dname,22).text
  }
  if ($did($dname,16).seltext == Level 100) {
    write level100.txt $did($dname,3).text
    timer 1 1 writeini nnames.ini $did($dname,3).text Address $did($dname,7).text
    timer 1 2 writeini nnames.ini $did($dname,3).text Apt $did($dname,9).text
    timer 1 3 writeini nnames.ini $did($dname,3).text Phone $did($dname,11).text
    timer 1 4 writeini nnames.ini $did($dname,3).text Prov/State $did($dname,13).text
    timer 1 5 writeini nnames.ini $did($dname,3).text City $did($dname,19).text
    timer 1 6 writeini nnames.ini $did($dname,3).text Email $did($dname,20).text
    timer 1 7 writeini nnames.ini $did($dname,3).text DOB $did($dname,22).text
  }
}

alias diag.size {
  set %sn 1
  while (%sn <= $5) {
    .dialog -srb $1 $2 $3 $4 %sn
    inc %sn
  }
}


Enjoy


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131636 02/10/05 10:29 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks a lot. That code works great. As you noted I do help out when & where I can, however, this is my first experimentation with dialogs, as dialogs require one on one interaction, and most of the coding that I've done has been for bots, where the interaction is done remotely, rather than directly.

#131637 02/10/05 10:43 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
yeah I love Dialogs so much its like creating a new program laugh

if you find a bug just tell me, im sure i looked the code over twice before i released it

Enjoy


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131638 03/10/05 05:49 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
After reviewing the code, and making several modifications, most of which worked with no problems, but there's one part that's got me stumped as to why it's not working.
I have marked the area that is giving me trouble with a remarked statement.
Here's the code as it currently stands, and a couple of examples regarding the format of the ini files where the information is stored
Code:
 alias obs {
  dialog -m Observer Observer
}
dialog Observer {
  title "Observer"
  size -1 -1 330 80
  option dbu
  button "Cancel", 1, 5 50 20 10, cancel
  button "OK", 2, 5 30 20 10, default ok
  button Store New Info, 3, 50 50 50 10, flat
  text "Rte", 4, 5 10 20 10
  combo 5, 20 10 30 10, edit drop
  text "Account", 6, 60 10 20 10
  combo 7, 80 10 60 10, size edit drop
  text "Name", 8, 150 10 25 10
  edit "", 9, 180 10 50 10, autohs
  text "Address", 10, 150 20 25 10
  edit "", 11, 180 20 50 10, autohs
  text "Apt.", 12, 240 20 20 10
  edit "", 13, 260 20 20 10, autohs
  text "Phone", 14, 150 40 25 10
  edit "", 15, 180 40 50 10, autohs
  combo 16, 180 30 50 10, edit drop
  check "Active", 17, 240 30 30 10, left
  combo 18, 180 50 50 10, edit drop
  text "Billing", 19, 150 50 20 10
  text "Delivery", 20, 150 30 25 10
  text "Expires", 21, 240 50 25 10
  edit "", 22, 260 50 40 8, autohs
  box User Info, 1000, 145 2 160 72
  text "Start", 23, 150 60 25 8
  text "Stop", 24, 240 60 25 8
  combo 25, 180 60 50 10, sort size edit drop
  combo 26, 260 60 40 10, sort size edit drop
}

on *:DIALOG:Observer:INIT:*: {
  %resize = on
  if (%resize == on) { .timer 1 0 /diag.size Observer -1 -1 320 70 }
  if !$lines(Observer.txt) {
    echo -a 8,1ALERT!!! No routes established
  }
  else {
    var %a = 1
    while %a <= $lines(Observer.txt) {
      did -a $dname 5 $read(Observer.txt,t,%a)
      inc %a
    }
  }
  ;
  did -a $dname 16 Daily
  did -a $dname 16 Sat. Only
  did -a $dname 16 MP/LL
  ;
  did -a $dname 18 Office
  did -a $dname 18 Monthly
  did -a $dname 18 Bi-wkly
  ;
  did -a $dname 25 $adate
}

on *:DIALOG:Observer:sclick:5: {
  var %rte = $did($dname,5).seltext
  if !$exists($+(%rte,.ini)) {
    echo -a 8,1ALERT!!!4,0 You have no entries for Rte %rte
  }
  else {
    var %obs.store = 1, %obs.calc = $ini($+(%rte,.ini),0)
    ;this section isn't loading the appropriate information to the drop box in the dialog
    while (%obs.store <= %obs.calc) {
      did -a $dname 7 $ini($+(%rte,.ini),%obs.store)
      inc %obs.store
    }
  }
}
on *:DIALOG:Observer:sclick:7: {
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext
  did -ra $dname 9 $readini(%file,n,%acct,Name)
  did -ra $dname 11 $readini(%file,n,%acct,Address)
  did -ra $dname 13 $readini(%file,n,%acct,Apt)
  did -ra $dname 15 $readini(%file,n,%acct,Phone)
  did -ra $dname 17 $readini(%file,n,%acct,Active)
  did -ra $dname 18 $readini(%file,n,%acct,Billing)
  did -ra $dname 16 $readini(%file,n,%acct,Deliveries)
  did -ra $dname 22 $readini(%file,n,%acct,Expiry)
}
on *:DIALOG:Observer:sclick:2: {
  var %file = $iif(!$did($dname,5).seltext,$did($dname,5),$did($dname,5).seltext)
  .write -s Observer.txt %file
  var %file = $+(%file,.ini)
  var %acct = $iif(!$did($dname,7).seltext,$did($dname,7),$did($dname,7).seltext)
  .writeini -n %file %acct Name $did($dname,9)
  .writeini -n %file %acct Address $did($dname,11)
  if ($did($dname,13)) {    .writeini -n %file %acct Apt $did($dname,13)  }
  if ($did($dname,15)) {  .writeini -n %file %acct Phone $did($dname,15) }
  .writeini -n %file %acct Active $did($dname,17).state
  .writeini -n %file %acct Billing $did($dname,18).seltext
  .writeini -n %file %acct Deliveries $did($dname,16).seltext
  .writeini -n %file %acct Expiry $iif($did($dname,22),$did($dname,22),$adate)
  if ($did($dname,17).edited == $true) {    did -a $dname $iif($did($dname,17).state,25,26) $adate  }
  .writeini -n %file %acct Start $didtok($dname,25,32)
  if $didtok($dname,26,32) {
    .writeini -n %file %acct Stop $didtok($dname,26,32)
  }
  echo -a Route $left(%file,-4) updated
}


on *:DIALOG:Observer:sclick:3: {
  var %file = $iif(!$did($dname,5).seltext,$did($dname,5),$did($dname,5).seltext)
  .write -s Observer.txt %file
  var %file = $+(%file,.ini)
  var %acct = $iif(!$did($dname,7).seltext,$did($dname,7),$did($dname,7).seltext)
  .writeini -n %file %acct Name $did($dname,9)
  .writeini -n %file %acct Address $did($dname,11)
  if ($did($dname,13)) {    .writeini -n %file %acct Apt $did($dname,13)  }
  if ($did($dname,15)) {  .writeini -n %file %acct Phone $did($dname,15) }
  .writeini -n %file %acct Active $did($dname,17).state
  .writeini -n %file %acct Billing $did($dname,18).seltext
  .writeini -n %file %acct Deliveries $did($dname,16).seltext
  .writeini -n %file %acct Expiry $iif($did($dname,22),$did($dname,22),$adate)
  if ($did($dname,17).edited == $true) {    did -a $dname $iif($did($dname,17).state,25,26) $adate  }
  .writeini -n %file %acct Start $didtok($dname,25,32)
  if $didtok($dname,26,32) {
    .writeini -n %file %acct Stop $didtok($dname,26,32)
  }
  echo -a Route $left(%file,-4) updated
}

alias diag.size {
  set %sn 1
  while (%sn <= $5) {
    .dialog -srb $1 $2 $3 $4 %sn
    inc %sn
  }
}
 

Code:
 [49077744]
Name=Dunn, Gladys
Address=135 Queen
Active=1
Billing=Office
Deliveries=Daily
Expiry=10/21/2005
Start=10/03/2005
[49071530]
Name=Odell, E
Address=150 Queen
Apt=102
Active=1
Billing=Office
Deliveries=Daily
Expiry=10/2/2005
Start=10/03/2005
 


I realize that there's quite a difference between what I had originally asked for help with, and what I'm asking for help with now. That's due to the fact that the two implementations are for different purposes.

#131639 03/10/05 08:23 AM
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Dont know if its still needed or not, but the following is much more efficient for adding than the original which duplicated a lot of code. And im not sure what reason there was for using timers, so just removed them.

on *:DIALOG:Observer:sclick:23: {
write $+(level,$$gettok($did($dname,16).seltext,2,32),.txt) $did($dname,3).text
writeini -n nnames.ini $did($dname,3).text Address $did($dname,7).text
writeini -n nnames.ini $did($dname,3).text Apt $did($dname,9).text
writeini -n nnames.ini $did($dname,3).text Phone $did($dname,11).text
writeini -n nnames.ini $did($dname,3).text Prov/State $did($dname,13).text
writeini -n nnames.ini $did($dname,3).text City $did($dname,19).text
writeini -n nnames.ini $did($dname,3).text Email $did($dname,20).text
writeini -n nnames.ini $did($dname,3).text DOB $did($dname,22).text
; Call alias to 'refresh' dialog here
}


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
#131640 03/10/05 05:45 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
the timer was because the info wasnt refreshing all over there was a conflict..

and dude your assigned the wrong did command you send it to a edit box rather then drop down.. drop down = COMBO box

Code:
  else {
    var %obs.store = 1, %obs.calc = $ini($+(%rte,.ini),0)
    ;this section isn't loading the appropriate information to the drop box in the dialog
    while (%obs.store <= %obs.calc) {
      did -a $dname 7 $ini($+(%rte,.ini),%obs.store)
[color:green]; this is being assigned to edit id 7 while only combo's i see in your table is 3 and 16[/color]
      inc %obs.store
    }


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131641 03/10/05 07:18 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
RusselB's does use 7 for a combo ID.


Invision Support
#Invision on irc.irchighway.net
#131642 03/10/05 07:36 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Well i found one thing so far... your not able to create a .txt file named observer because your causing a -s switch (scan) so remove the write -s observer.txt $file just remove the -s so it can store Route... on file so accessable all time smile

more to come... still troubleshooting sorry im not completly understanding the large code completly but ill get around it.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131643 03/10/05 08:50 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
well rus the ONLY prob i beleive why nothing was going into your DID 7 is BECAUSE look at your table.. combo ID, x y w h, size edit drop

right?? that was yours

DO NOT use size in a combo without justify the combo drop size so therefore keep it as is..

combo ID, x y w h, edit drop

LMAO this was giving me a headache till i decided to manually type from command line /did -a Observer 7 TEXT and it didnt go through then i looked at the table and saw it there.. smile well here is the whole dialog mate

note DO NOT EDIT size of dialog itself for scroll effect to take place note i put a 0 in the height of it because the alias itself at the bottom while automatically justify size

Code:
alias obs {
  dialog -m Observer Observer
}
dialog Observer {
  title "Observer"
  size -1 -1 330 0
  option dbu
  button "Cancel", 1, 5 50 20 10, cancel
  button "OK", 2, 5 30 20 10, default ok
  button Store New Info, 3, 50 50 50 10, flat
  text "Rte", 4, 5 10 20 10
  combo 5, 20 10 30 10, edit drop
  text "Account", 6, 60 10 20 10
  combo 7, 80 10 60 10, sort edit drop
  text "Name", 8, 150 10 25 10
  edit "", 9, 180 10 50 10, autohs
  text "Address", 10, 150 20 25 10
  edit "", 11, 180 20 50 10, autohs
  text "Apt.", 12, 240 20 20 10
  edit "", 13, 260 20 20 10, autohs
  text "Phone", 14, 150 40 25 10
  edit "", 15, 180 40 50 10, autohs
  combo 16, 180 30 50 10, edit drop
  check "Active", 17, 240 30 30 10, left
  combo 18, 180 50 50 10, edit drop
  text "Billing", 19, 150 50 20 10
  text "Delivery", 20, 150 30 25 10
  text "Expires", 21, 240 50 25 10
  edit "", 22, 260 50 40 8, autohs
  box User Info, 1000, 145 2 160 72
  text "Start", 23, 150 60 25 8
  text "Stop", 24, 240 60 25 8
  combo 25, 180 60 50 10, sort size edit drop
  combo 26, 260 60 40 10, sort size edit drop
}

on *:DIALOG:Observer:INIT:*: {
  %resize = on
  if (%resize == on) { .timer 1 0 /diag.size Observer -1 -1 320 78 }
  if !$lines(Observer.txt) {
    echo -a 8,1ALERT!!! No routes established
  }
  else {
    var %a = 1
    while (%a <= $lines(Observer.txt)) {
      did -a $dname 5 $read(Observer.txt,%a)
      inc %a
    }
  }
  ;
  did -a $dname 16 Daily
  did -a $dname 16 Sat. Only
  did -a $dname 16 MP/LL
  ;
  did -a $dname 18 Office
  did -a $dname 18 Monthly
  did -a $dname 18 Bi-wkly
  ;
  did -a $dname 25 $adate
}

on *:DIALOG:Observer:sclick:5: {
  var %rte = $did($dname,5).seltext
  if !$exists($+(%rte,.ini)) {
    echo -a 8,1ALERT!!!4,1 You have no entries for Rte %rte
  }
  else {
    var %obs.store = 1, %obs.calc = $ini($+(%rte,.ini),0)
    ;this section isn't loading the appropriate information to the drop box in the dialog
    while (%obs.store <= %obs.calc) {
      did -a $dname 7 $ini($+(%rte,.ini),%obs.store)
      inc %obs.store
    }
  }
}


on *:DIALOG:Observer:sclick:7: {
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext
  did -ra $dname 9 $readini(%file,n,%acct,Name)
  did -ra $dname 11 $readini(%file,n,%acct,Address)
  did -ra $dname 13 $readini(%file,n,%acct,Apt)
  did -ra $dname 15 $readini(%file,n,%acct,Phone)
  did -ra $dname 17 $readini(%file,n,%acct,Active)
  did -ra $dname 18 $readini(%file,n,%acct,Billing)
  did -ra $dname 16 $readini(%file,n,%acct,Deliveries)
  did -ra $dname 22 $readini(%file,n,%acct,Expiry)
}
on *:DIALOG:Observer:sclick:2: {
  var %file = $iif(!$did($dname,5).seltext,$did($dname,5),$did($dname,5).seltext)
  .write Observer.txt %file
  var %file = $+(%file,.ini)
  var %acct = $iif(!$did($dname,7).seltext,$did($dname,7),$did($dname,7).seltext)
  .writeini -n %file %acct Name $did($dname,9)
  .writeini -n %file %acct Address $did($dname,11)
  if ($did($dname,13)) {    .writeini -n %file %acct Apt $did($dname,13)  }
  if ($did($dname,15)) {  .writeini -n %file %acct Phone $did($dname,15) }
  .writeini -n %file %acct Active $did($dname,17).state
  .writeini -n %file %acct Billing $did($dname,18).seltext
  .writeini -n %file %acct Deliveries $did($dname,16).seltext
  .writeini -n %file %acct Expiry $iif($did($dname,22),$did($dname,22),$adate)
  if ($did($dname,17).edited == $true) {    did -a $dname $iif($did($dname,17).state,25,26) $adate  }
  .writeini -n %file %acct Start $didtok($dname,25,32)
  if $didtok($dname,26,32) {
    .writeini -n %file %acct Stop $didtok($dname,26,32)
  }
  echo -a Route $left(%file,-4) updated
}


on *:DIALOG:Observer:sclick:3: {
  var %file = $iif(!$did($dname,5).seltext,$did($dname,5),$did($dname,5).seltext)
  .write Observer.txt %file
  .write Account.txt $did($dname,7).text
  var %file = $+(%file,.ini)
  var %acct = $iif(!$did($dname,7).seltext,$did($dname,7),$did($dname,7).seltext)
  .writeini -n %file %acct Name $did($dname,9)
  .writeini -n %file %acct Address $did($dname,11)
  if ($did($dname,13)) {    .writeini -n %file %acct Apt $did($dname,13)  }
  if ($did($dname,15)) {  .writeini -n %file %acct Phone $did($dname,15) }
  .writeini -n %file %acct Active $did($dname,17).state
  .writeini -n %file %acct Billing $did($dname,18).seltext
  .writeini -n %file %acct Deliveries $did($dname,16).seltext
  .writeini -n %file %acct Expiry $iif($did($dname,22),$did($dname,22),$adate)
  if ($did($dname,17).edited == $true) {    did -a $dname $iif($did($dname,17).state,25,26) $adate  }
  .writeini -n %file %acct Start $didtok($dname,25,32)
  if $didtok($dname,26,32) {
    .writeini -n %file %acct Stop $didtok($dname,26,32)
  }
  echo -a Route $left(%file,-4) updated
}

alias diag.size {
  set %sn 1
  while (%sn <= $5) {
    .dialog -srb $1 $2 $3 $4 %sn
    inc %sn
  }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131644 04/10/05 12:14 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks for your help. I don't understand why it works with your code, but not what I had, however, it does.
Next problem I've encountered is in this section
Code:
 on *:DIALOG:Observer:sclick:7: {  
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext  
  did -ra $dname 9 $readini(%file,n,%acct,Name)  
  did -ra $dname 11 $readini(%file,n,%acct,Address)  
  did -ra $dname 13 $readini(%file,n,%acct,Apt)  
  did -ra $dname 15 $readini(%file,n,%acct,Phone)  
  did $iif($readini(%file,n,%acct,Active),-c,-u) $dname 17
  did -ra $dname 18 $readini(%file,n,%acct,Billing)  
  did -ra $dname 16 $readini(%file,n,%acct,Deliveries)  
  did -ra $dname 22 $readini(%file,n,%acct,Expiry)
}
 

I had to change the /did for item 17 to get it to work correctly.
However, the information read from the ini file isn't being displayed for items 16 & 18. It does display if I select that item, but I'd like that to show automatically, and still be able to change it by selecting the item, if necessary.
For example if Billing is Daily, it should show Daily in the display, and allow me to be able to change it to Sat Only or MP/LL

I also edited the other combo boxes so that they all use edit drop...removed size, and sort, where applicable.

I also just noticed that when the information is written to the text files, currently there are two text files being written to, Observer.txt and Account.txt, the information is written to each file, even if the information already exists. This causes the drop down box for the Rte # to have multiple entries for each route. I don't understand why you have Account.txt being written, as I can't find any reference to that file anywhere else in the code.

Last edited by RusselB; 04/10/05 01:45 AM.
#131645 04/10/05 03:38 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Oops delete write account.txt that was my bad... i was just testing lol
its not neccessary

btw the only 2 changes you had to do in your original code is remove Size from the combo 7, xywh, drop edit section

and remove -s from write -s observer.txt .......... thats it


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131646 04/10/05 03:53 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:


Code:
 on *:DIALOG:Observer:sclick:7: {  
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext  
  did -ra $dname 9 $readini(%file,n,%acct,Name)  
  did -ra $dname 11 $readini(%file,n,%acct,Address)  
  did -ra $dname 13 $readini(%file,n,%acct,Apt)  
  did -ra $dname 15 $readini(%file,n,%acct,Phone)  
  did $iif($readini(%file,n,%acct,Active),-c,-u) $dname 17
  did -r[color:red]c[/color]a $dname 18 $readini(%file,n,%acct,Billing)  
  did -r[color:red]c[/color]a $dname 16 $readini(%file,n,%acct,Deliveries)  
  did -ra $dname 22 $readini(%file,n,%acct,Expiry)
}
 




just remember TV RCA brand if you got a combo box and want info to pop right away just do -RCA :P

btw i see more size in your combo boxes remove then what i mean is

combo ID, X Y W H, drop edit... you keep putting size there remove that


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131647 04/10/05 04:02 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
without the -s (and yes, I realized afterwards that I was forgetting to include the search term), every time I add a new entry, the route number gets written to the Observer.txt file

I've got a total of nearly 400 entries over 13 routes, and I don't see why I would have to have the route numbers written to the text file 400 times, when it could be just once per route (a total of 13 entries)

Originally I had /write -s Observer.txt %file
which should've read /write -s $+ %file Observer.txt %file
so that if the value of %file was already in Observer.txt it would just be written over
instead it seems like you're saying I have to use /write Observer.txt %file
which, as I said earlier, would make a text file with about 400 entries in it, when there's only 13 different values

Regarding the other changes you mentioned, I've either already changed them, or will do so soon.

I've already removed the size parameter, for lack of a better term, from the combo boxes.

I was doing some entries, then checked them, and noticed that the entry for Start keeps going to 12/31/1969, no matter what I enter for the date at that location. At the moment it's a small matter, but one that should get fixed up. If it helps, I was using a default date of 09/01/2005

#131648 04/10/05 04:57 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:
without the -s (and yes, I realized afterwards that I was forgetting to include the search term), every time I add a new entry, the route number gets written to the Observer.txt file

I've got a total of nearly 400 entries over 13 routes, and I don't see why I would have to have the route numbers written to the text file 400 times, when it could be just once per route (a total of 13 entries)

Originally I had /write -s Observer.txt %file
which should've read /write -s $+ %file Observer.txt %file
so that if the value of %file was already in Observer.txt it would just be written over
instead it seems like you're saying I have to use /write Observer.txt %file
which, as I said earlier, would make a text file with about 400 entries in it, when there's only 13 different values

Regarding the other changes you mentioned, I've either already changed them, or will do so soon.

I've already removed the size parameter, for lack of a better term, from the combo boxes.

I was doing some entries, then checked them, and noticed that the entry for Start keeps going to 12/31/1965, no matter what I enter for the date at that location. At the moment it's a small matter, but one that should get fixed up. If it helps, I was using a default date of 09/01/2005


im not sure what your reffering too because your INIT is (partial code)

did -a $dname 16 MP/LL
;
did -a $dname 18 Office
did -a $dname 18 Monthly
did -a $dname 18 Bi-wkly
;
did -ca $dname 25 $adate
}

which $adate = Actual date (today right now OCT 4th 2005) so it should prompt adate (IF BY ANYCHANCE YOU STILL GET SAME ERROR CHECK YOUR PC CLOCK I BET YOU ITS THE YEAR YOUR SAYING)

sorry for caps but i wanted to make that stand out

please explain just a lil more thanks

also ill point out something since you said your kinda a beginner on dialog coding... I noticed you said if ($did($dname,17).edited << now 17 = a checkbox and edited wouldnt help so within the sorta code you got following ... it well anyone it should be

if ($did($dname,17).state == 1) << this means if checkbox = checked

if ($did($dname,17).state == 0) << this means if checkbox = unchecked

Code:
*******************your code***************************8
if ($did($dname,17).edited == $true) {    did -a $dname $iif($did($dname,17).state,25,26) $adate  }
  .writeini -n %file %acct Start $didtok($dname,25,32)
  if $didtok($dname,26,32) {
    .writeini -n %file %acct Stop $didtok($dname,26,32)
  }
  echo -a Route $left(%file,-4) updated
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131649 04/10/05 08:39 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Found the problem...stupid mistake on my part.

As to $did($dname,17).edited, I want the current date to go into one of two locations depending on if the box is checked or not, but only if the check box was changed.

It might not be the greatest for coding, but it works

#131650 04/10/05 12:05 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Coolio is all good now?


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131651 04/10/05 01:17 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
/write -s should work just fine as long as you're using the correct format (including the $+ %file like you mentioned).


Invision Support
#Invision on irc.irchighway.net
#131652 04/10/05 02:44 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
yeah tus why i said to remove it.. i didnt know he wanted to use the scan switch for that purpose


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131653 06/10/05 08:49 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The code works fine, however, I was wondering if a few extras could be implemented.
1) Allow the date entries to be entered using one of the following:
A) a single number, which would default to an entry of that day in the current month, returning an error if that date doesn't exist
B) mmm dd, which would default to that date in the current year
C) allow for mmm dd yy, or mmm dd yyyyy, or m/d/yy, or m/d/yyyy

I already have a line so that the date will default to the current date if there is no entry, but if it's not one of the above mentioned formats, then I should get an error message

2) could someone also code a phone number look up?
The site I'd use would be http://findaperson.canada411.ca/ with the city & province being preset. The name is supplied in the dialog, and will be in the format of Surname, Given Name. Address is also in the dialog.

I understand that this second item will require usage of sockets, and I tried to find a very basic socket tutorial in order to try to do it myself, but all of the tutorials I found required you to already have a basic knowledge of sockets...which at the moment is more than I have.
If the socket code could also include detailed documentation as to what's happening where and why, it would be appreciated as I prefer to understand a code, even if it's longer than necessary, rather than having a short code that I don't understand.

#131654 10/10/05 09:39 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
OK, I've got the date configuration working the way I want, but I'm still having trouble understanding sockets in order to get the phone number information from the website. I realize that scripts aren't usually written for a one time usage, and that I could look up the phone numbers one at a time, but I've got nearly 500 numbers to look up, so I was thinking that using a script, even just once, would save a lot of time.

#131655 18/10/05 05:54 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Well, I've had a bit of luck with this, and here's the code that I've currently got. Problem is, it's not returning the proper value, and I'm not sure why. There isn't any error messages being generated, but I don't seem to be getting a response either.
Code:
 on *:DIALOG:Observer:sclick:7: {  
  save.data 
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext  
  did -ra $dname 9 $readini(%file,n,%acct,Name)  
  did -ra $dname 11 $readini(%file,n,%acct,Address)  
  did -ra $dname 13 $readini(%file,n,%acct,Apt)  
  if !$readini(%file,n,%acct,Phone) { 
    var %surname = $iif($numtok($did($dname,9),44) &gt; 1,$gettok($did($dname,9),1,44),$did($dname,9)) 
    var %given = $iif(%surname != $did($dname,9),$gettok($did($dname,9),2,44)) 
    .enable phone 
    find.a.person %surname $iif(%given,%given) 
  } 
  did -a $dname 15 $readini(%file,n,%acct,Phone)  
  did $iif($readini(%file,n,%acct,Active),-c,-u) $dname 17 
  did -rca $dname 18 $readini(%file,n,%acct,Billing)  
  did -rca $dname 16 $readini(%file,n,%acct,Deliveries)  
  did -ra $dname 22 $readini(%file,n,%acct,Expiry) 
  did -rca $dname 25 $gettok($readini(%file,n,%acct,Start),-1,32) 
  did -rca $dname 26 $gettok($readini(%file,n,%acct,Stop),-1,32) 
} 
#phone off 
alias find.a.person { 
  if (!$isid) { 
    set %firstname $1 
    set %lastname $2 
    sockopen findap findaperson.canada411.ca 80 
  } 
} 
on *:sockopen:findap:{ 
  sockwrite -n $sockname GET $+(/10649/search/Find_Person?firstname=,%firstname,&amp;name=,%lastname,&amp;city_zip=Sarnia&amp;state_id=ON) HTTP/1.1 
  sockwrite -n $sockname Host: findaperson.canada411.ca $+ $crlf $+ $crlf 
} 
on *:sockread:findap:{ 
  if ($sockerr) { 
    echo -a some error occored oh no. 
    return 
  } 
  else { 
    var %nc 
    sockread %nc 
    if $wildtok(%nc,$+(*,%lastname,*),0,95) { 
      var %fulladdress = $gettok(%nc,5,61) 
      var %apt = $right($gettok(%fulladdress,2,37),-2) 
      var %street = $gettok($replace($gettok(%fulladdress,3-,37),20,$chr(32)),1,38) 
      var %address = $+($gettok(%fulladdress,1,37),%street) 
      if $did($dname,11) == %address &amp;&amp; $did($dname,13) == %apt { 
        did -a $dname 15 $right($gettok($gettok(%nc,11,61),1,38),8) 
      } 
    } 
    if (%nc == &lt;/HTML&gt;) { sockclose findap } 
  } 
} 
#phone end 
 

#131656 18/10/05 01:21 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, you are getting invalid data in your socket..

If I echo your variables when searching for a random name that I know is on the site:

(I put this inside your IF statement):
echo -a %fulladdress ~ %apt ~ %street ~ %address

Results:
Quote:

"regular_field" maxlength ~ ~ ~ "regular_field" maxlength
85%20Maplestone%20Ave&_RM_HTML_STREET_ESC_ ~ Maplestone ~ Ave ~ 85 Ave
~ ~ ~
10180201443947680553&amp;sort ~ ~ ~ 10180201443947680553&amp;sort
~ ~ ~
~ ~ ~

As you can see, this is obviously invalid data.

Try:

Code:
    if (*RM_HTML_FIRST_ESC* iswm %nc) { 
      var %fulladdress = $gettok(%nc,5,61) 
      var %apt = $right($gettok(%fulladdress,2,37),-2) 
      var %street = $gettok($replace($gettok(%fulladdress,3-,37),20,$chr(32)),1,38) 
      var %address = $+($gettok(%fulladdress,1,37),%street) 

      echo -a %fulladdress ~ %apt ~ %street ~ %address
    } 


I removed the DID information because I don't have your dialog table to test it with. Just insert that back in once you have it working on the //echo with the correct data. Is this the right data in your variables?

%fulladdress === 85%20Maplestone%20Ave&_RM_HTML_STREET_ESC_
%apt === Maplestone
%street === Ave
%address === 85 Ave


The change I did was to fix your IF... you didn't need to check for that $wildtok text as that brought up unneeded results. This brings up only one result.


Invision Support
#Invision on irc.irchighway.net
#131657 19/10/05 04:02 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks for your help Riamus2. That has helped solve the problem I was having, however, one thing I didn't think of before, is what if there's more than one match on the search? How do I go about ensuring that I get the information for the correct match? For example, if I search for A. Smith in Sarnia, ON...I get 10 results...How do I ensure that the phone number is for the right A. Smith?

Sort of on the same topic, I've found that some of the people have an apartment number of 2 in my listings, yet in the directory, it's marked as 1/2. I can't seem to get the apartment number to change to match what is in the directory.

Here's the socket read section of my code as I currently have it
Code:
 on *:sockread:findap:{ 
  if ($sockerr) { 
    echo -a some error occored oh no. 
    return 
  } 
  else { 
    var %nc 
    sockread %nc 
    if (*RM_HTML_FIRST_ESC* iswm %nc) {
      var %nc = $replace(%nc,$+($chr(37),20),$chr(32))
      var %last = $gettok($gettok(%nc,4,61),1,38)
      var %first = $iif(!%firstname,$gettok($gettok(%nc,3,61),1,38),%firstname)
      var %address = $gettok($gettok(%nc,7,61),1,38)
      var %apt = $gettok(%address,-1,32)
      var %address = $gettok(%address,1,32)
      var %street = $gettok($gettok(%nc,6,61),1,38)
      var %phone = $gettok($gettok($gettok(%nc,-3,61),1,38),-1,32)
    }
    ;    if $did(Observer,13) != %apt {      did -a Observer 13 %apt    }
    if !$did(Observer,15) &amp;&amp; %phone {      did -a Observer 15 %phone    }
    if (%nc == &lt;/HTML&gt;) { sockclose findap } 
  } 
}
 


The line is remarked at the moment, due to the fact that it doesn't work. When I tried it, as written, it changed 2 to 21/2

#131658 19/10/05 01:02 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Use /did -ra to change a value. -a appends. You need -r to remove what is already there.

As for knowing the correct person, you would need to have some idea of what address is the correct one. You could then compare it to determine which is right. Alternatively, you could have it store the ones that have multiple addresses in a file or a hash table or wherever and then go through them manually, later. If you could give an example from your listing that has multiple listings on the website, I may be able to set it up to automatically choose the right one. If you don't want to include a real address/name, then go on there and pick some random name, like I did, that brings up multiple names and then make a "fake" part to match how it would appear in your listing so I can compare the two. If you can give a few examples, it would help out.


Invision Support
#Invision on irc.irchighway.net
#131659 20/10/05 12:00 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The address in Number Street Name format is in $did(Observer,11). The apartment number, if applicable, is in $did(Observer,13)

I did a test run using A Smith and got 10 listings. Saving the results to a html file, then viewing that file in Notepad showed a file with 707 lines. I have edited that down so that it the following contains just the relevant information (or at least I hope I didn't remove information that was relevant and/or include irrelevant information)

I've pasted the information here as it shows in Notepad with WordWrap turned off
Quote:
<SCRIPT language=javascript1.1 type=text/javascript
xmlns:str="http://exslt.org/strings">
<!--
// SITE: Canada 411
// PAGE: PERS_RESULTS_1
oas_url = 'http://oasads.whitepages.com/RealMedia/ads/';
oas_sitepage = 'canada411.whitepages.com/RESULTS';
oas_listpos = 'Medium_Rect,Popunder,HeadingText,ResultsLink3,ResultsLink2,x50,Banner';
oas_rn = '01234567890';
oas_rns = '1234567890';
oas_rn = new String(Math.random());
oas_rns = oas_rn.substring(2,11);
oas_version = 10;
oas_query = '?'+"_RM_HTML_FIRST_ESC_=A&_RM_HTML_LAST_ESC_=Smith&_RM_HTML_ADDRESS_ESC_=341%20Mitton%20St%20S&_RM_HTML_STREET_ESC_=Mitton%20St%20S&_RM_HTML_HOUSE_ESC_=341&_RM_HTML_CITY_ESC_=Sarnia&_RM_HTML_STATE_ESC_=ON&_RM_HTML_ZIP_ESC_=N7T%203E4&_RM_HTML_PHONE_ESC_=(519)%20337-0861&CITY=Sarnia&STATE=ON";
oas_target = '_top';
function OAS_NORMAL(pos) {
document.write('<a href="' + oas_url + 'click_nx.ads/' + oas_sitepage + '/1' + oas_rns + '\@' + oas_listpos + '!' + pos + oas_query + '" target=' + oas_target + '>');
document.write('<img src="' + oas_url + 'adstream_nx.ads/' + oas_sitepage + '/1' + oas_rns + '\@' + oas_listpos + '!' + pos + oas_query + '" border=0></a>');
}
// -->
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_1','__FIRST__',"A");
swapElementText('resultlink_1','__LAST__',"Smith");
swapElementText('resultlink_1','__CITY__',"Sarnia");
swapElementText('resultlink_1','__STATE__',"ON");
swapElementText('resultlink_1','__ADDRESS_ESC__',"341%20Mitton%20St%20S");
swapElementText('resultlink_1','__FIRST_ESC__',"A");
swapElementText('resultlink_1','__LAST_ESC__',"Smith");
swapElementText('resultlink_1','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_1','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_2','__FIRST__',"A");
swapElementText('resultlink_2','__LAST__',"Smith");
swapElementText('resultlink_2','__CITY__',"Sarnia");
swapElementText('resultlink_2','__STATE__',"ON");
swapElementText('resultlink_2','__ADDRESS_ESC__',"664%20Murphy%20Rd");
swapElementText('resultlink_2','__FIRST_ESC__',"A");
swapElementText('resultlink_2','__LAST_ESC__',"Smith");
swapElementText('resultlink_2','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_2','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_3','__FIRST__',"A");
swapElementText('resultlink_3','__LAST__',"Smith");
swapElementText('resultlink_3','__CITY__',"Sarnia");
swapElementText('resultlink_3','__STATE__',"ON");
swapElementText('resultlink_3','__ADDRESS_ESC__',"114%20Hanna%20Cres");
swapElementText('resultlink_3','__FIRST_ESC__',"A");
swapElementText('resultlink_3','__LAST_ESC__',"Smith");
swapElementText('resultlink_3','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_3','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_4','__FIRST__',"A & K");
swapElementText('resultlink_4','__LAST__',"Smith");
swapElementText('resultlink_4','__CITY__',"Sarnia");
swapElementText('resultlink_4','__STATE__',"ON");
swapElementText('resultlink_4','__ADDRESS_ESC__',"1625%20Aftoncrt");
swapElementText('resultlink_4','__FIRST_ESC__',"A%20&%20K");
swapElementText('resultlink_4','__LAST_ESC__',"Smith");
swapElementText('resultlink_4','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_4','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_5','__FIRST__',"A Chris");
swapElementText('resultlink_5','__LAST__',"Smith");
swapElementText('resultlink_5','__CITY__',"Sarnia");
swapElementText('resultlink_5','__STATE__',"ON");
swapElementText('resultlink_5','__ADDRESS_ESC__',"231%20Cobden%20St");
swapElementText('resultlink_5','__FIRST_ESC__',"A%20Chris");
swapElementText('resultlink_5','__LAST_ESC__',"Smith");
swapElementText('resultlink_5','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_5','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_6','__FIRST__',"A E");
swapElementText('resultlink_6','__LAST__',"Smith");
swapElementText('resultlink_6','__CITY__',"Sarnia");
swapElementText('resultlink_6','__STATE__',"ON");
swapElementText('resultlink_6','__ADDRESS_ESC__',"345%20Willowdale%20Cres");
swapElementText('resultlink_6','__FIRST_ESC__',"A%20E");
swapElementText('resultlink_6','__LAST_ESC__',"Smith");
swapElementText('resultlink_6','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_6','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_7','__FIRST__',"A P");
swapElementText('resultlink_7','__LAST__',"Smith");
swapElementText('resultlink_7','__CITY__',"Sarnia");
swapElementText('resultlink_7','__STATE__',"ON");
swapElementText('resultlink_7','__ADDRESS_ESC__',"780%20Alexander%20St");
swapElementText('resultlink_7','__FIRST_ESC__',"A%20P");
swapElementText('resultlink_7','__LAST_ESC__',"Smith");
swapElementText('resultlink_7','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_7','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_8','__FIRST__',"Allen W");
swapElementText('resultlink_8','__LAST__',"Smith");
swapElementText('resultlink_8','__CITY__',"Sarnia");
swapElementText('resultlink_8','__STATE__',"ON");
swapElementText('resultlink_8','__ADDRESS_ESC__',"1053%20Talfourd%20St");
swapElementText('resultlink_8','__FIRST_ESC__',"Allen%20W");
swapElementText('resultlink_8','__LAST_ESC__',"Smith");
swapElementText('resultlink_8','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_8','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_9','__FIRST__',"Andy");
swapElementText('resultlink_9','__LAST__',"Smith");
swapElementText('resultlink_9','__CITY__',"Sarnia");
swapElementText('resultlink_9','__STATE__',"ON");
swapElementText('resultlink_9','__ADDRESS_ESC__',"515%20Erindale%20Crt");
swapElementText('resultlink_9','__FIRST_ESC__',"Andy");
swapElementText('resultlink_9','__LAST_ESC__',"Smith");
swapElementText('resultlink_9','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_9','__STATE_ESC__',"ON");
</SCRIPT>
<SCRIPT language=javascript type=text/javascript
xmlns:str="http://exslt.org/strings">
swapElementText('resultlink_10','__FIRST__',"Anthony");
swapElementText('resultlink_10','__LAST__',"Smith");
swapElementText('resultlink_10','__CITY__',"Sarnia");
swapElementText('resultlink_10','__STATE__',"ON");
swapElementText('resultlink_10','__ADDRESS_ESC__',"1011%20Frost%20Ave");
swapElementText('resultlink_10','__FIRST_ESC__',"Anthony");
swapElementText('resultlink_10','__LAST_ESC__',"Smith");
swapElementText('resultlink_10','__CITY_ESC__',"Sarnia");
swapElementText('resultlink_10','__STATE_ESC__',"ON");
</SCRIPT>

#131660 20/10/05 04:34 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
NOTE: You can view the source without saving it to an HTML file by right clicking in your browser and choosing "View Source". If you use something other than IE, it may be called something else, or may be located under a View menu or something similar. (IE also has it in the View menu).

Ok, let's see if I know for sure what you're trying to do...

You have a bunch of addresses in your dialog and you're trying to update them with the phone number?

If that's the case, we already have the address off the website thanks to the socket...

Put the variables for the parts of the address into the correct order and check if they equal the dialog value. If so, insert the phone number.

Something like:

Code:
if ($did(Observer,11) == %address %street) {
  did -ra Observer [color:red][Phone's ID][/color] [color:blue]%phone [/color][color:green](see below for where this comes from)[/color]
}


To get the phone variable to use above, insert this into the same place where you're setting the address variables:

Code:
var %phone = $replace($gettok($gettok(%nc,11,61),1,38),$+(%,20),$chr(32))



One other note, you probably should put your %apt changing part into that IF section, too. Otherwise, if you happen to have only one match and it's the wrong one, the apartment will be changed even when it shouldn't be. If you put it into this IF statement, then you'll only change the apartment if the rest of the address matches.


Invision Support
#Invision on irc.irchighway.net
#131661 20/10/05 04:58 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Basically, yes, that's the situation. Thanks for you help, I'll fix up the code and try it. As I think I mentioned before, I could do this one by one, but with nearly 500 entries, it would take a while.

And thanks for the note about viewing the source. I wasn't aware I could do that, so I went with a method I knew would work.

#131662 20/10/05 05:44 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I've tested this, and noted a few problems, but I'm too tired at the moment to write them up, and try to explain what it is I'm wanting versus what I'm getting, so I'll probably do that tomorrow when I get up.

#131663 20/10/05 01:13 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, sounds good. smile


Invision Support
#Invision on irc.irchighway.net
#131664 20/10/05 11:47 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
When reading the information from the site, if there's no apartment number, then the apartment number is defaulting to the same as the house number in the address field.
Also wondered if there was a way to set it so that it doesn't look up information for people that already have all the information entered. Additonally, I was wondering if there's a way of speeding up the process of getting the information from the site. Currently I'm seeing times of between 4000 and 18000 ticks. I'm not exactly sure how long a tick is, but it was the easiest way to get a timing. I'm currently using a 1M DSL connection.

The information in the Start field (Observer,25) and the Stop field (Observer,26) always come back empty. I realize that's nothing to do with the sockets.

My full code, as it currently stands is
Code:
 alias obs {
  dialog -m Observer Observer
}
dialog Observer {
  title "Observer"
  size -1 -1 300 100
  option dbu
  button "Cancel", 1, 10 40 20 10, cancel
  button "OK", 2, 40 40 20 10, ok
  button Store New Info, 3, 10 60 50 10, default
  text "Rte", 4, 10 10 20 10
  combo 5, 30 10 30 10, edit drop
  text "Account", 6, 10 20 20 10
  combo 7, 30 20 60 10, edit drop
  text "Name", 8, 100 10 25 10
  edit "", 9, 130 10 50 10, autohs
  text "Address", 10, 100 20 25 10
  edit "", 11, 130 20 50 10, autohs
  text "Apt.", 12, 190 20 20 10
  edit "", 13, 210 20 20 10, autohs
  text "Phone", 14, 100 40 25 10
  edit "", 15, 130 40 50 10, autohs
  combo 16, 130 30 50 10, edit drop
  check "Active", 17, 190 30 30 10, left
  combo 18, 130 50 50 10, edit drop
  text "Billing", 19, 100 50 20 10
  text "Delivery", 20, 100 30 25 10
  text "Expires", 21, 190 50 25 10
  edit "", 22, 220 50 50 10, autohs
  box User Info, 1000, 95 2 180 92
  text "Start", 23, 100 60 25 8
  text "Stop", 24, 190 60 25 8
  combo 25, 130 60 50 10, edit drop
  combo 26, 220 60 50 10, edit drop
  edit "", 27, 130 70 50 10
  text "Balance", 28, 100 70 25 8
  text "Pay Date", 29, 100 80 25 8
  text "Amount", 31, 190 80 25 8
  combo 32, 130 80 50 10, edit drop
  edit "", 33, 220 80 50 10
}
on *:DIALOG:Observer:INIT:*: {
  unset %edited
  if !$lines(Observer.txt) {        echo -a 8,1ALERT!!! No routes established    }
  else {
    var %a = 1
    while %a &lt;= $lines(Observer.txt) {
      did -a $dname 5 $read(Observer.txt,t,%a)
      inc %a    
    }  
  }  
  ;  
  did -a $dname 16 Daily  
  did -a $dname 16 Sat. Only  
  did -a $dname 16 MP/LL  
  ;  
  did -a $dname 18 Office  
  did -a $dname 18 Monthly  
  did -a $dname 18 Bi-wkly  
  ;  
  did -rca $dname 25 $adate
}

on *:DIALOG:Observer:sclick:5: {  
  var %rte = $did($dname,5).seltext  
  if !$exists($+(%rte,.ini)) {    echo -a 8,1ALERT!!!4,1 You have no entries for Rte %rte    }
  else {
    var %obs.store = 1, %obs.calc = $ini($+(%rte,.ini),0)   
    while (%obs.store &lt;= %obs.calc) {
      did -a $dname 7 $ini($+(%rte,.ini),%obs.store)      
      inc %obs.store    
    }  
    if $did($dname,16).sel == 3 {      unset %collect    }
    elseif $did($dname,16).sel == 1 {
    }
  }
}
alias save.data {
  if %edited {
    var %file = $iif(!$did($dname,5).seltext,$did($dname,5),$did($dname,5).seltext)  
    .write -s $+ %file Observer.txt %file
    var %file = $+(%file,.ini),%acct = $iif(!$did($dname,7).seltext,$did($dname,7),$did($dname,7).seltext)  
    .writeini -n %file %acct Name $did($dname,9)  
    .writeini -n %file %acct Address $did($dname,11)  
    $iif(!$did($dname,13),.remini %file %acct Apt,.writeini -n %file %acct Apt $did($dname,13))
    $iif(!$did($dname,15),.remini %file %acct Phone,.writeini -n %file %acct Phone $did($dname,15))
    .writeini -n %file %acct Active $did($dname,17).state  
    .writeini -n %file %acct Billing $did($dname,18).seltext  
    .writeini -n %file %acct Deliveries $did($dname,16).seltext  
    .writeini -n %file %acct Expiry $iif($did($dname,22),$did($dname,22),$adate)  
    if $did($dname,17).edited {    did -a $dname $iif($did($dname,17).state,25,26) $adate    }
    .writeini -n %file %acct Start $didtok($dname,25,32)  
    if $didtok($dname,26,32) {        .writeini -n %file %acct Stop $didtok($dname,26,32)    }
    if $didtok($dname,32,32) {        .writeini -n %file %acct Paid $didtok($dname,32,32)    }
  }
  unset %edited
}
on *:DIALOG:Observer:sclick:7: {  
  set %ticks $ticks
  save.data
  var %file = $+($did($dname,5).seltext,.ini), %acct = $did($dname,7).seltext  
  did -ra $dname 9 $readini(%file,n,%acct,Name)  
  did -ra $dname 11 $readini(%file,n,%acct,Address)  
  did -ra $dname 13 $readini(%file,n,%acct,Apt)  
  if !$readini(%file,n,%acct,Phone) {
    var %surname = $iif($numtok($did($dname,9),44) &gt; 1,$gettok($did($dname,9),1,44),$did($dname,9))
    var %given = $iif(%surname != $did($dname,9),$gettok($did($dname,9),2,44))
    find.a.person %surname $iif(%given,%given)
  }
  did $iif($readini(%file,n,%acct,Active),-c,-u) $dname 17
  did -rca $dname 18 $readini(%file,n,%acct,Billing)  
  did -rca $dname 16 $readini(%file,n,%acct,Deliveries)  
  did -ra $dname 22 $readini(%file,n,%acct,Expiry)
  did -rca $dname 25 $gettok($readini(%file,n,%acct,Start),-1,32)
  did -rca $dname 26 $gettok($readini(%file,n,%acct,Stop),-1,32)
}
alias find.a.person { 
  if (!$isid) { 
    ;set the searchterm to be used later on when we suply the url 
    set %lastname $1 
    set %firstname $2 
    sockopen findap findaperson.canada411.ca 80 
  } 
} 
on *:sockopen:findap:{ 
  sockwrite -n $sockname GET $+(/10649/search/Find_Person?firstname=,%firstname,&amp;name=,%lastname,&amp;city_zip=Sarnia&amp;state_id=ON) HTTP/1.1 
  sockwrite -n $sockname Host: findaperson.canada411.ca $+ $crlf $+ $crlf 
} 
on *:sockread:findap:{ 
  if ($sockerr) { 
    echo -a some error occored oh no. 
    return 
  } 
  else { 
    var %nc 
    sockread %nc 
    if (*RM_HTML_FIRST_ESC* iswm %nc) {
      echo -a $calc($ticks - %ticks)
      var %nc = $replace(%nc,$+($chr(37),20),$chr(32))
      var %last = $gettok($gettok(%nc,4,61),1,38)
      var %first = $iif(!%firstname,$gettok($gettok(%nc,3,61),1,38),%firstname)
      var %address = $gettok($gettok(%nc,7,61),1,38)
      var %apt = $gettok(%address,-1,32)
      var %address = $gettok(%address,1,32)
      var %street = $gettok($gettok(%nc,6,61),1,38)
      var %phone = $gettok($gettok($gettok(%nc,-3,61),1,38),-1,32)
      if ($did(Observer,11) == %address %street) &amp;&amp; ($did(Observer,13) == %apt) {
        did -ra Observer 15 %phone
      }
      elseif ($did(Observer,11) == %address %street) {
        did -ra Observer 13 %apt
        did -ra Observer 15 %phone
      }
    }
    if (%nc == &lt;/HTML&gt;) { sockclose findap } 
  } 
  echo -a $calc($ticks - %ticks)
}
on *:DIALOG:Observer:sclick:2,3: {
  save.data
}
 

#131665 21/10/05 03:54 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok...

1) Use this to set your %apt information... the other method wouldn't work because all that it was doing was displaying the last word in %address... and %address was just the street number.
Code:
      if (*%23* iswm $gettok($gettok(%nc,5,61),1,38)) {
        var %apt = $gettok($gettok($gettok(%nc,5,61),1,38),-1,32)
      }


2) If you want to avoid looking things up, then you'd need to do a check on the name... basically: If ($did(Observer,ID) == $null || $did(Observer,ID2) == $null) { get name from site } else { don't }

(I'll let you code that... if you have questions after you try, let me know).

3) The best way to speed up sockets is to stop the socket before the end of the page. Look at the source code and find the first unique piece of code following the last data you need and then sockclose on that instead of on </html>. Depending on where your data is in the source, you could save a lot of time this way... but if your data is right near the end, it won't really make much difference. In this case, I think I'd stop with:

if (<div style="text-align:left;* iswm %nc) { sockclose findap }

It won't save a lot of time, but it will save some.

4) Just a note... the site splits the results onto multiple pages... this will cause you a LOT of problems if your correct names aren't on page 1. You may have to start another socket up to pull up page 2 and then page 3 and so on... it's rather troublesome to need to do that. And I don't see any options on the site for allowing 50 (or some other large number) names per page... it's at 10 by default.


Invision Support
#Invision on irc.irchighway.net
#131666 21/10/05 08:42 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
As you noted, there's a chance of the correct match not being on the first page, and I've also found that even if it is on the first page, if it's not the first one encountered, then my code comes up incorrect.

This works if there's only one match or if the first match is the correct one. Any suggestions as to how to handle the other possibilities?
Code:
 on *:sockread:findap:{ 
  if ($sockerr) { 
    echo -a some error occored oh no. 
    return 
  } 
  else { 
    var %nc 
    sockread %nc 
    if (*_RM_HTML_* iswm %nc) {
      var %nc = $replace(%nc,$+($chr(37),20),$chr(32)), %token = 1
      while %token &lt; $wildtok(%nc,*_RM_HTML_*,0,61) {
        var %item = $gettok($wildtok(%nc,*_RM_HTML_*,%token,61),4,95)
        var %info = $gettok($wildtok(%nc,$+(*,%item,*),1,38),-1,61)
        if (%item == Address) {
          var %address = $iif(!$did(Observer,13),$did(Observer,11),$instok($did(Observer,11),$did(Observer,13),2,32))
          if (%address == %info) {          set %correct 1        }
        }
        inc %token
      }
      var %item = $gettok($wildtok(%nc,*_RM_HTML_*,%token,61),4,95)
      var %info = $gettok($wildtok(%nc,$+(*,%item,*),1,38),-1,61)
      if %correct {
        did -ra Observer 15 %info
        unset %correct
      }
      else {        echo 4 -a %item %info      }
    }
    if (&lt;LINK* iswm %nc) {      sockclose findap    }
  } 
}
 

#131667 21/10/05 01:42 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, the problem is that you are really looking in the wrong place for address information. I took a look at the source a bit more...

Try this instead of you if (*_RM_HTML_* iswm %nc) { section that you have now:

Code:
    if (&lt;div class="textb"* iswm %nc) {
      var %last = $remove($gettok(%nc,-1,62),$chr(44))
      sockread %nc
      var %first = $gettok($gettok(%nc,-1,9),1,60)
    }
    if (&lt;div class="text"&gt;* iswm %nc) {
      var %address = $gettok($gettok(%nc,2,62),1,60)
      var %phone = $gettok($gettok(%nc,4,62),1,60)
      [color:blue]; This splits %address into street number, street name, and apartment variables.
      ; It's optional depending on whether you really need them split apart like that...[/color]
      var %streetnum = $gettok(%address,1,32)
      var %streetname = $gettok($gettok(%address,2-,32),1,44)
      var %apt = $gettok(%address,2,44)
    }


Note that this assumes all apartment numbers have a comma before them. If that's not the case, swap the two 44's (commas) to 35's (#'s) and then $remove the commas from %streetname.

Notice the embedded sockread? In some cases, this is necessary. If not done properly, it can lead to some weird results, but when it is done correctly, you can get some lines that have no unique characters on them. You *could* use an IF to make this work in this case if you didn't want to use an embedded sockread... (perhaps regex would as well, for that matter). But, the embedded sockread is easier to do. laugh


Invision Support
#Invision on irc.irchighway.net
Page 1 of 2 1 2

Link Copied to Clipboard