Print Page | Close Window

Translation help please

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9469
Printed Date: 29 March 2026 at 4:41am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Translation help please
Posted By: huwnet
Subject: Translation help please
Date 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]);
?>




Replies:
Posted By: huwnet
Date Posted: 03 February 2004 at 1:33pm


Posted By: Bullschmidt
Date Posted: 05 February 2004 at 6:37am

How about trying this:

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



-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)


Posted By: Bullschmidt
Date 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 - http://faq.ozoneasylum.com/1083



-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)


Posted By: huwnet
Date 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.


Posted By: pmormr
Date Posted: 06 February 2004 at 8:40am
translate it with bullschdmit's converter and repost it here and we'll check it

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 06 February 2004 at 8:41am
ha... haven't seen the printf command since regular old C

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: huwnet
Date 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 http://www.php-asp-convertor.com/conversionnotes.htm - notes )
MySQL / SQL commands are not yet translated properly.
I think there are some other errors as well.



Posted By: huwnet
Date Posted: 12 February 2004 at 11:22am
I am desperate!!! can anyone help?


Posted By: Mart
Date Posted: 12 February 2004 at 11:47am
Have you runned it? Does it work? If not what errors do you get?


Posted By: pmormr
Date Posted: 12 February 2004 at 5:49pm
look at the IF statement structure on that... of course it won't run.. give me a little while to translate it... What the cash sign ($) mean in PHP?

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 12 February 2004 at 5:51pm
half of these functions are used for high level programming languages like C++ not ASP... you got yourself a problem, is there even a sizeof function in ASP?

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: huwnet
Date Posted: 13 February 2004 at 11:22am
As I have said, I know nothing about ASP. If it cannot be translated into ASP then ASP.NET would do fine!
Thanks for the help so far.


Posted By: pmormr
Date Posted: 13 February 2004 at 2:49pm
alright... i need a list of all the special PHP commands that didn't get translated (i.e. $ sign). and also, if you used any functions, please tell me what they do

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 13 February 2004 at 3:00pm
i'm guessing that the $ sign signifies a special variable... kinda like ServerVariables...

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 13 February 2004 at 3:01pm
p.s. you can access my progress at http://www.illgetit.info/untitled3.txt - http://www.illgetit.info/untitled3.txt

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 13 February 2004 at 3:04pm
i have a better idea... why don't you just tell me exactly what this code is doing and i'll rewrite it in ASP instead of trying to translate from a language that i'm unfamiliar with

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: huwnet
Date Posted: 15 February 2004 at 1:29pm
Ok this script connects to the HTML page with my statistics at grid.org (the full address is in the PHP script) and then displays them.


Posted By: Mart
Date Posted: 15 February 2004 at 2:40pm
All variables in PHP need to be prefixed with a $... thats what its for.


Posted By: huwnet
Date Posted: 10 April 2004 at 5:29am
Originally posted by pmormr pmormr wrote:

i have a better idea... why don't you just tell me exactly what this code is doing and i'll rewrite it in ASP instead of trying to translate from a language that i'm unfamiliar with


What is the status of this?


Posted By: Mart
Date Posted: 10 April 2004 at 8:02am

You can do it in .net  with 2 lines of code:

Dim wc As New System.Net.WebClient

Response.BinaryWrite(wc.DownloadData("http://www.whatever.co m"))



Posted By: Semikolon
Date Posted: 10 April 2004 at 8:22am

ASP

<%
Dim
objXMLHTTP
On Error Resume Next
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", "address", False
objXMLHTTP.Send
If ErrNum <> 0 Then
 Response.Write(vbCrLf & "<font size=""3"" color=""#FF0000""><strong>")
 Response.Write(vbCrLf & " Failed to contact the server!!")
 Response.Write(vbCrLf & " <br />Please check your internet connection and try again.")
 Response.Write(vbCrLf & "</strong></font>")
Else
 Response.Write(objXMLHTTP.responseText)
End If
Set objXMLHTTP = Nothing
%>




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net