mIRC Homepage

parsing this massive string

Posted By: pouncer

parsing this massive string - 26/04/07 12:15 AM

Code:
alias test {
var %str = <tr id='find1'><td class=StyleTahoma valign=up>Dennie™</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Dennie™"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=!!!!! CAFE MOJITO !!!!!'>!!!!! CAFE MOJITO !!!!!</a><br><a href='chatroom.php?rm=BCNTrivia'>BCNTrivia</a><br><a href='chatroom.php?rm=Jewels Place'>Jewels Place</a><br><a href='chatroom.php?rm=EspressoBar'>EspressoBar</a><br><a href='chatroom.php?rm=Leuteenergie'>Leuteenergie</a><br><a href='chatroom.php?rm=Scriptz Help'>Scriptz Help</a><br><a href='chatroom.php?rm=GrapevineEdge'>GrapevineEdge</a><br><a href='chatroom.php?rm=EspressoBar_2'>EspressoBar_2</a><br><a href='chatroom.php?rm=EspressoBar_3'>EspressoBar_3</a><br><a href='chatroom.php?rm=TienersHangout'>TienersHangout</a><br><a href='chatroom.php?rm=Chat Cafe'>Chat Cafe</a><br><a href='chatroom.php?rm=AfterHours'>AfterHours</a><br><a href='chatroom.php?rm=Liefde en Romantiek'>Liefde en Romantiek</a><br><a href='chatroom.php?rm=Babbelboxke'>Babbelboxke</a><br><a href='chatroom.php?rm=Trivia Room'>Trivia Room</a><br><a href='chatroom.php?rm=30plus'>30plus</a><br><a href='chatroom.php?rm=Scriptez-Domain'>Scriptez-Domain</a><br><a href='chatroom.php?rm=Tannies Poolbar'>Tannies Poolbar</a><br><a href='chatroom.php?rm=GrapevineEdge_2'>GrapevineEdge_2</a><br><a href='chatroom.php?rm=DragonsDomain'>DragonsDomain</a><br><a href='chatroom.php?rm=WebbyCove'>WebbyCove</a><br><a href='chatroom.php?rm=~ !!Blondes ~ Flirty ~ Chat !! ~'>~ !!Blondes ~ Flirty ~ Chat !! ~</a><br><a href='chatroom.php?rm=!!!!!!!!!!!!!!~FLIRTATIOUS~MINDS~'>!!!!!!!!!!!!!!~FLIRTATIOUS~MINDS~</a><br><a href='chatroom.php?rm=Gezellig-Limburgs'>Gezellig-Limburgs</a><br></td></tr></table>
}


how can i possibly parse something like this? i'm trying to get it to echo each rooms which the user is in - about 20 in the string, but its almost impossible with /set ling too long error
Posted By: Spitfire3292

Re: parsing this massive string - 26/04/07 12:41 AM

Check out binary variables. Specifically make your sockread &var then use $bvar and $bfind to help yah get to a specific point in the string. Sorry I cant give more advice to you right now, I got to run! Hope I helped!
Posted By: MeStinkBAD

Re: parsing this massive string - 26/04/07 10:37 AM

How about just FIXING the line length limit al together!
Posted By: Rand

Re: parsing this massive string - 26/04/07 12:33 PM

That would be something Khaled would have to do. And I honestly don't see it happening any time soon.

Binary Variables are about the only way for you to specifically deal with extremely long lines.
Posted By: pouncer

Re: parsing this massive string - 26/04/07 08:59 PM

can you guys give me a binvar example please on how to deal with it?
Posted By: pouncer

Re: parsing this massive string - 29/04/07 05:05 PM

please guys, anyone?
Posted By: hixxy

Re: parsing this massive string - 29/04/07 06:27 PM

Code:
alias getroom {
  if (!$bvar($1,0)) { return }
  var %pos = $bfind($1,1,?rm=) + 4
  while (%pos != 4) {
    echo -a $bvar($1,$+(%pos,-,$calc($bfind($1,%pos,') - 1))).text
    %pos = $bfind($1,%pos,?rm=) + 4
  }
}


You just have to pass the name of the binary variable you read the data into to /getroom. This just echos the rooms to the active window, you can change that to whatever you like.
Posted By: pouncer

Re: parsing this massive string - 29/04/07 11:33 PM

hey hixxy, your code worked an absolute treat!!! one other problem i have is if the search page contains rooms which found more than 1 user

e.g, if i search for 'dave' it finds, Swtdave, dave1981, etc.. and lists their rooms, how could i show this data also?

Code:
<tr id='find1'><td class=StyleTahoma valign=up>Swtdave</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Swtdave"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=BBW Big Bold n Spicy'>BBW Big Bold n Spicy</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>BroDave</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=BroDave"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Christians~Meeting~Christians'>Christians~Meeting~Christians</a><br></td></tr><tr id='find1'><td class=StyleTahoma valign=up>DaveFla</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=DaveFla"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Natural Attire'>Natural Attire</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>Dave13733</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Dave13733"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Political Chat for Grownups'>Political Chat for Grownups</a><br></td></tr><tr id='find1'><td class=StyleTahoma valign=up>DANNYS_BOY_DAVE1939</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=DANNYS_BOY_DAVE1939"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=THE OLDER THAN DIRT ROOM'>THE OLDER THAN DIRT ROOM</a><br></td></tr></table>
Posted By: hixxy

Re: parsing this massive string - 30/04/07 10:59 AM

It should already do that, since all it does is grab the text between every instance of ?rm= and '
Posted By: pouncer

Re: parsing this massive string - 30/04/07 11:38 AM

thanks for the reply hixy. yeah it displays all that every user is in

but doesnt dislay the username
Posted By: hixxy

Re: parsing this massive string - 30/04/07 05:30 PM

Code:
alias getroom {
  if (!$bvar($1,0)) { return }
  var %pos = $bfind($1,1,?name=) + 6, %pos2, %next
  while (%pos != 6) {
    %next = $iif($bfind($1,%pos,?name=),$v1,$bvar($1,0))
    echo -a Rooms for $bvar($1,$+(%pos,-,$calc($bfind($1,%pos,") - 1))).text $+ :
    %pos2 = $bfind($1,%pos,?rm=) + 4
    while (%pos2 != 4) && (%pos2 < %next) {
      echo -a $bvar($1,$+(%pos2,-,$calc($bfind($1,%pos2,') - 1))).text
      %pos2 = $bfind($1,%pos2,?rm=) + 4
    }
    %pos = $bfind($1,%pos,?name=) + 6
  }
}
Posted By: pouncer

Re: parsing this massive string - 30/04/07 05:35 PM

hixxy that alias is now perfect, thanks alot.

can i ask what the +6 and +4 are doing though?
Posted By: hixxy

Re: parsing this massive string - 30/04/07 06:03 PM

%pos is set to the occurrence of ?name=, which is six letters long, but we don't want to include that in the /echo, so we add 6 to it.

Same applies to %pos2, but ?rm= is only 4 long.
Posted By: pouncer

Re: parsing this massive string - 02/05/07 01:39 PM

hey hixxy, after testing it for a while, i've it sometimes displays the results wrong :s e.g

Code:
<tr id='find1'><td class=StyleTahoma valign=up>GardenBot1</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=GardenBot1"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Garden Of Light'>Garden Of Light</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>IdentityCrisisBH</td><td class=StyleTahoma></td><td class=StyleTahoma><a href='chatroom.php?rm=Philochat'>Philochat</a><br></td></tr><tr id='find1'><td class=StyleTahoma valign=up>GoldenEagle</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=GoldenEagle"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=`The Round Table'>`The Round Table</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>Hidden™</td><td class=StyleTahoma></td><td class=StyleTahoma><a href='chatroom.php?rm=lebanon'>lebanon</a><br></td></tr><tr id='find1'><td class=StyleTahoma valign=up>dandenver</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=dandenver"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=wizetraders'>wizetraders</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>Arthur_Dent</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Arthur_Dent"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=!!!!!The_Dark_Side!!!!!'>!!!!!The_Dark_Side!!!!!</a><br><a href='chatroom.php?rm=!!!!!!!!!!AMERICA!!!!!!!!!! ~ War On Terror! ~ News! ~ Politics!'>!!!!!!!!!!AMERICA!!!!!!!!!! ~ War On Terror! ~ News! ~ Politics!</a><br></td></tr><tr id='find1'><td class=StyleTahoma valign=up>Deco-Den</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Deco-Den"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Bi Married Men4Men'>Bi Married Men4Men</a><br><a href='chatroom.php?rm=!!!!!!!!!!!!!!!!!!!!!!!!!!!!5TR8_M3N_W_G@Y_URG35'>!!!!!!!!!!!!!!!!!!!!!!!!!!!!5TR8_M3N_W_G@Y_URG35</a><br><a href='chatroom.php?rm=!!!!!!!!!!!!!!!!!!!HOTT AND BOTHERED COME IN'>!!!!!!!!!!!!!!!!!!!HOTT AND BOTHERED COME IN</a><br></td></tr><tr id='find2'><td class=StyleTahoma valign=up>Golden</td><td class=StyleTahoma><a href="../members/usrProfile.php?name=Golden"><img border="0" src='../webincludes/icons/userNbr.gif'></a></td><td class=StyleTahoma><a href='chatroom.php?rm=Scriptez-Domain'>Scriptez-Domain</a><br><a href='chatroom.php?rm=InventioN'>InventioN</a><br><a href='chatroom.php?rm=!!!!!!!!!!!!!!~FLIRTATIOUS~MINDS~'>!!!!!!!!!!!!!!~FLIRTATIOUS~MINDS~</a><br><a href='chatroom.php?rm=Scripters'>Scripters</a><br><a href='chatroom.php?rm=hackers'>hackers</a><br></td></tr></table>


for e.g it displays:
Code:
Rooms for GardenBot1:
Garden Of Light
Philochat


which is wrong, because its the user 'IdentityCrisisBH' thats in PhiloChat.

any ideas mate?
© 2019 mIRC Discussion Forums