Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Translation help please
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Translation help please

 Post Reply Post Reply Page  123>
Author
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post Topic: Translation help please
    Posted: 02 February 2004 at 12:16pm

Can someone please help me translate this code into ASP. I have tried it with the PHP>>ASP.NET converter but there were errors I didn't know how to fix! I know nothing about asp. Thanks

<?

/* (c) Graham Eames 2002
   Code in this file may be re-used or modified providing this copyright notice is retained */

function read_stats($username)
{
/* Convert the query string into a valid string to pass to the file function */
  $usercode = ereg_replace(" ", "+", $username);
/* Generate the URL of the page on the UD site we require */
/* The ord=CPU_TIME_PER_DAY is used to force a sort which makes the data extraction simpler */
  $url= "http://www.grid.org/stats/members/compare.htm?un1=".$userco de."&ord=CPU_TIME_PER_DAY";
/* Read the contents of the statistics page into an array */
  $fcontents = file ($url);
  $output=false;
  $section="";
/* Examine the contents of the file line-by-line */
  for($line=0;$line<sizeof($fcontents);$line++)
  {
/* When we detect this string in the file, we are approaching the area we want in the file so enable the next test */
    if (ereg("ord=CPU_TIME\"", $fcontents[$line]))
    {
      $output=true;
      $section = "CPU_TIME";
    }
/* If we are in the right are of the file, then start checking for the line we want*/
    if (($output==true) && ($section == "CPU_TIME"))
    {
/* The time line is the first one to start with "<td" in this area of the file */
      if (ereg("\<td", $fcontents[$line]))
      {
/* The time figure is surrounded by <b> and </b> so cut this from the centre of the line */
        $q = split("<b>", $fcontents[$line]);
        $q = split("</b>", $q[1]);
        $time = $q[0];
/* Disable the tests again as we have this figure */
        $output=false;
        $section = "";
      }
    }
/* When we detect this string in the file, we are approaching the area we want in the file so enable the next test */
    if (ereg("ord=POINTS\"", $fcontents[$line]))
    {
      $output=true;
      $section = "POINTS";
    }
/* If we are in the right are of the file, then start checking for the line we want*/
    if (($output==true) && ($section == "POINTS"))
    {
/* The points line is the first one to start with "<td" in this area of the file */
      if (ereg("\<td", $fcontents[$line]))
      {
/* The time figure is surrounded by <b> and </b> so cut this from the centre of the line */
        $q = split("<b>", $fcontents[$line]);
        $q = split("</b>", $q[1]);
        $points = $q[0];
/* Disable the tests again as we have this figure */
        $output=false;
        $section = "";
      }
    }
/* When we detect this string in the file, we are approaching the area we want in the file so enable the next test */
    if (ereg("ord=RESULTS\"", $fcontents[$line]))
    {
      $output=true;
      $section = "RESULTS";
    }
/* If we are in the right are of the file, then start checking for the line we want*/
    if (($output==true) && ($section == "RESULTS"))
    {
/* The results line is the first one to start with "<td" in this area of the file */
      if (ereg("\<td", $fcontents[$line]))
      {
/* The results figure is surrounded by <b> and </b> so cut this from the centre of the line */
        $q = split("<b>", $fcontents[$line]);
        $q = split("</b>", $q[1]);
        $results = $q[0];
        $output = false;
        $section = "";
        $line = sizeof($fcontents);
        $return[0] = $time;
        $return[1] = $points;
        $return[2] = $results;
        return $return;
/* Finally break out of the loop, as we do not need to parse any more of the file */
        break;
      }
    }
  }
}

$figures = read_stats("huwnet");
printf("CPU Time = %s<br>\n", $figures[0]);
printf("Points = %s<br>\n", $figures[1]);
printf("Results = %s<br>\n", $figures[2]);
?>



Edited by huwnet
Back to Top
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2004 at 1:33pm
Back to Top
Bullschmidt View Drop Down
Groupie
Groupie


Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bullschmidt Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 6:37am

How about trying this:

http://www.php-asp-convertor.com



Edited by Bullschmidt
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
Back to Top
Bullschmidt View Drop Down
Groupie
Groupie


Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bullschmidt Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 6:42am

And I got that last link from here:

Can I convert from ASP to PHP or from PHP to ASP?  -  1083
http://faq.ozoneasylum.com/1083

J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
Back to Top
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 12:37pm
The problem is I don't know any programming at all! I cannot fix the stuff I dosen't translate.
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 06 February 2004 at 8:40am
translate it with bullschdmit's converter and repost it here and we'll check it
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 06 February 2004 at 8:41am
ha... haven't seen the printf command since regular old C
Back to Top
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post Posted: 07 February 2004 at 5:37am
Code tranlated:

<%
Dim gv_figures, gv_figures()


/*(c)Graham Eames 2002Code in this file may be re-used or modified providing this copyright notice is retained */Function fn_read_stats ( lv_username )

    Dim lv_username, lv_usercode, lv_url, lv_line, lv_fcontents, lv_output, lv_section, lv_return(), lv_time, lv_points, lv_results, lv_return
        ' multiline comment removed
    lv_usercode  = ereg_replace(" ", "+", lv_username)
    ' multiline comment removed
    ' multiline comment removed
    lv_url = "http://www.grid.org/stats/members/compare.htm?un1=" & $userco de."&ord=CPU_TIME_PER_DAY"
    ' multiline comment removed
    $fcontents  = file ($url)
    $output = false
    $section = ""
    ' multiline comment removed
    For lv_line = 0 to sizeof(lv_fcontents)
        ' multiline comment removed
        If ereg("ord=CPU_TIME""", $fcontents[$line]) then
            $output = true
            $section  = "CPU_TIME"
        End If

' multiline comment removed
        If (lv_output==true) && (lv_section == "CPU_TIME") then
            ' multiline comment removed
            If ereg("\<td", $fcontents[$line]) then
                ' multiline comment removed
                $q  = split("<b>", $fcontents[$line])
                $q  = split("</b>", $q[1])
                $time  = $q[0]
                ' multiline comment removed
                $output = false
                $section  = ""
            End If
End If

' multiline comment removed
        If ereg("ord=POINTS""", $fcontents[$line]) then
            $output = true
            $section  = "POINTS"
        End If

' multiline comment removed
        If (lv_output==true) && (lv_section == "POINTS") then
            ' multiline comment removed
            If ereg("\<td", $fcontents[$line]) then
                ' multiline comment removed
                $q  = split("<b>", $fcontents[$line])
                $q  = split("</b>", $q[1])
                $points  = $q[0]
                ' multiline comment removed
                $output = false
                $section  = ""
            End If
End If

' multiline comment removed
        If ereg("ord=RESULTS""", $fcontents[$line]) then
            $output = true
            $section  = "RESULTS"
        End If

' multiline comment removed
        If (lv_output==true) && (lv_section == "RESULTS") then
            ' multiline comment removed
            If ereg("\<td", $fcontents[$line]) then
                ' multiline comment removed
                $q  = split("<b>", $fcontents[$line])
                $q  = split("</b>", $q[1])
                $results  = $q[0]
                $output  = false
                $section  = ""
                lv_line  = sizeof(lv_fcontents)
                lv_return(0)  = lv_time
                lv_return(1)  = lv_points
                lv_return(2)  = lv_results
                fn_read_stats = lv_return
                ' multiline comment removed
                breakEnd If
End If
Next
End Function

gv_figures  = read_stats("huwnet")
    printf("CPU Time =%s<br>\n",gv_figures(0));
printf("Points =%s<br>\n",gv_figures(1));
printf("Results =%s<br>\n",
%>

Errors:
Function names do not have the fn_ prefix added when they are called (see notes)
MySQL / SQL commands are not yet translated properly.
I think there are some other errors as well.

Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.