|
-
Feb 6th, 2005, 06:59 PM
#1
Thread Starter
Member
PHP to VB6
Hey, I was wondering if someone could help me convert this from PHP to VB script.
Thanks in advance 
Code:
foreach($file as $value) {
$fval .= $value;
}
if(preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)) {
$i = 0;
foreach($matches as $value) {
foreach($value as $value) {
if($i == 1) {
$skill[] = $value;
}
}
$i++;
}
}
if(preg_match_all('/<td align="right">\n(.*)\n<\/td><td/', $fval, $matches)) {
$i = 0;
foreach($matches as $value) {
foreach($value as $value) {
if($i == 1) {
$level[] = $value;
}
}
$i++;
}
}
function skill($sskill) {
global $skill, $level;
if(!isset($skill)) {
return '--';
}
else {
foreach($skill as $key => $value) {
if($value == $sskill) {
return $level[$key];
$i = 1;
}
}
if(!isset($i)) {
return '--';
}
}
}
$overall = skill('Overall');
$attack = skill('Attack');
$defence = skill('Defence');
$strength = skill('Strength');
$hitpoints = skill('Hitpoints');
$ranged = skill('Ranged');
$prayer = skill('Prayer');
$magic = skill('Magic');
$cooking = skill('Cooking');
$woodcutting = skill('Woodcutting');
$fletching = skill('Fletching');
$fishing = skill('Fishing');
$firemaking = skill('Firemaking');
$crafting = skill('Crafting');
$smithing = skill('Smithing');
$mining = skill('Mining');
$herblore = skill('Herblore');
$agility = skill('Agility');
$thieving = skill('Thieving');
$slayer = skill('Slayer');
$runecrafting = skill('Runecrafting');
-
Feb 7th, 2005, 06:12 AM
#2
Re: PHP to VB6
 Originally Posted by Jonno12345
Hey, I was wondering if someone could help me convert this from PHP to VB script.
Thanks in advance
Code:
foreach($file as $value) {
$fval .= $value;
}
if(preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)) {
$i = 0;
foreach($matches as $value) {
foreach($value as $value) {
if($i == 1) {
$skill[] = $value;
}
}
$i++;
}
}
if(preg_match_all('/<td align="right">\n(.*)\n<\/td><td/', $fval, $matches)) {
$i = 0;
foreach($matches as $value) {
foreach($value as $value) {
if($i == 1) {
$level[] = $value;
}
}
$i++;
}
}
function skill($sskill) {
global $skill, $level;
if(!isset($skill)) {
return '--';
}
else {
foreach($skill as $key => $value) {
if($value == $sskill) {
return $level[$key];
$i = 1;
}
}
if(!isset($i)) {
return '--';
}
}
}
$overall = skill('Overall');
$attack = skill('Attack');
$defence = skill('Defence');
$strength = skill('Strength');
$hitpoints = skill('Hitpoints');
$ranged = skill('Ranged');
$prayer = skill('Prayer');
$magic = skill('Magic');
$cooking = skill('Cooking');
$woodcutting = skill('Woodcutting');
$fletching = skill('Fletching');
$fishing = skill('Fishing');
$firemaking = skill('Firemaking');
$crafting = skill('Crafting');
$smithing = skill('Smithing');
$mining = skill('Mining');
$herblore = skill('Herblore');
$agility = skill('Agility');
$thieving = skill('Thieving');
$slayer = skill('Slayer');
$runecrafting = skill('Runecrafting');
What is that? Looks like its for a game called Runescape (I used to play log time agao) had a good character,
What does the code do?
-
Feb 7th, 2005, 07:28 AM
#3
Thread Starter
Member
Re: PHP to VB6
 Originally Posted by Pino
What is that? Looks like its for a game called Runescape (I used to play log time agao) had a good character,
What does the code do?
Got it in one 
It parses the data (in this case, peoples levels) from the runescape hiscores and places them into variables. I have seen it used many a time in VB6, but nobody will let on their code So I found a PHP version and can't make head nor tail of it, which is why I need a little help 
Thanks in advance.
-
Feb 8th, 2005, 11:29 AM
#4
Re: PHP to VB6
Do you want this in VB Script/ASP (VB Script) or VB 6? The barrier here is the use of a regular expression. I can convert the rest of the code for you but implementing the string matching in the regular expressions is very complex without a regular expression parser and I do not have the time to do this.
I suggest you post a thread in the VB6 or VB Script / ASP forum asking how to use your regular expressions in VB. I have heard that there is a library but have never used it.
For your information the regular expression is that complex looking string in the preg_match() function:
Code:
preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)
In this case the regular expression will match the text between the <td><a> tags of the string and dump the result in an array,. i.e. it will match among others:
<td><a href="hiscoreuser.cgi?value=4563&category=value" calss=c>Some Link Text</a></td>
<td><a href="hiscoreuser.cgi?value=453663&category=another" calss=c>Some Link Text</a></td>
<td><a href="hiscoreuser.cgi?value=444&category=someother" calss=c>Some Link Text</a></td>
The bold areas of the text must always be present for a match to occur. The italic areas can vary. This is the reason they are called regular expressions and would require, character by character analysis of the string in VB.
-
Feb 9th, 2005, 02:08 AM
#5
Junior Member
Re: PHP to VB6
You could use the RegExp object:
RegExp
It's been a while since I've used it, so I don't remember if they are PCRE or not, so you may have to rewrite the regexp as seen in the PHP example.
If there is a way to solve your problems, there is no need to worry; if there is no way to solve your problems, there is no point to worry.
-
Feb 12th, 2005, 01:44 PM
#6
Fanatic Member
Re: PHP to VB6
This may be an extraneous post since I'm a few days behind the last one, but...
I would suggest rewritting the regexp by replacing the "\n" with ".+$". This will allow you to match anything, or nothing, to the end of the line (in case there is added whitespace or another carriage return other than \n).
Also, you might have to escape the special characters, such as changing "?" to "\?" and "." to "\.", but I'm not sure about that..you would in perl but maybe not in VB script.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|