Redirect in Speedscript

BadSector

New Member
Hi

Is there an equivalent to PHP's header command to redirect to another page?

I have an online form that uses POST to post to itself i.e. the processing is done in the same form. I want to seperate the processing from the form to avoid issues like reposting when refreshing etc.

I know, rtfm, but I've spent too much time r'ing the f'ing m already and hoped you could provide a quick answer.

Thanks in advance and hopefully this will also help another noob.
 

BadSector

New Member
OK - I've used a quick and dirty workaround: autorefresh with a check to see if ReqBy has been entered. The refresh seems to flush POST variables, taking ReqBy back to it's default value.

Code:
IF REQUEST_METHOD = "POST":U and get-value("ReqBy")<> "Enter Name" THEN DO:
create BytesBRD.
Assign Benefits = get-value("Benefit").
.
./*Assign*/
. 
{&OUT} '<meta HTTP-EQUIV="REFRESH" content="0; url=../submitBRD.html">'.
End.

I hope this helps someone but i would still like to know how to redirect in Speedscript.

Thanks
 

ashah

New Member
hi

THis is code for redirect to other page

output-http-header​
("Status":U, "302 Redirect":U).

output-http-header​
("Location":U, "/cgi-bin/demo.sh/restart.w":U).

output-http-header​
("", "").

 

israelm

New Member
OK - I've used a quick and dirty workaround: autorefresh with a check to see if ReqBy has been entered. The refresh seems to flush POST variables, taking ReqBy back to it's default value.

Code:
IF REQUEST_METHOD = "POST":U and get-value("ReqBy")<> "Enter Name" THEN DO:
create BytesBRD.
Assign Benefits = get-value("Benefit").
.
./*Assign*/
. 
{&OUT} '<meta HTTP-EQUIV="REFRESH" content="0; url=../submitBRD.html">'.
End.
I hope this helps someone but i would still like to know how to redirect in Speedscript.

Thanks

I've tried all the ways i have found posted on different forums and documentation and nothing seems be useful.

If i find anything i'll let you know. Anyway thank's for the codes.

Best Regards!
 

webguy

Member
What ashah posted will work using output headers with webspeed. Another trick that many people dont know about is that you can use a run statement. the trick is that you cant do this and pass parameters like you can using javascript redirect or headers.​

So say I check for something and based on its value I redirect I can do something like this:​

Code:
[LEFT]if v-redirect then
do:
run mywebspeedfiles/redirect.html.
return.
end.[/LEFT]

Above I just use a run statement using a relative path to the folder called mywebspeedfiles containing my compiled webspeed code. redirect.html must be a compiled webspeed file with a .r. You cant do this with any file.​


What you cant do with this method, or at least what I've found you cant do is something like this:​

Code:
[LEFT]if v-redirect then
do:
run mywebspeedfiles/redirect.html?name=joe&id=333.
return.
end.[/LEFT]

So if you want to do a redirect and pass values to the page javascript or headers will work better.​


By the way this example that you posted shown below is using run to call a procedure. What i showed above is not really the same thing as calling a procedure.​
RUN run-web-object (INPUT "main.p").​
 

israelm

New Member
What ashah posted will work using output headers with webspeed. Another trick that many people dont know about is that you can use a run statement. the trick is that you cant do this and pass parameters like you can using javascript redirect or headers.​

So say I check for something and based on its value I redirect I can do something like this:​

Code:
[LEFT]if v-redirect then
do:
run mywebspeedfiles/redirect.html.
return.
end.[/LEFT]
Above I just use a run statement using a relative path to the folder called mywebspeedfiles containing my compiled webspeed code. redirect.html must be a compiled webspeed file with a .r. You cant do this with any file.​


What you cant do with this method, or at least what I've found you cant do is something like this:​

Code:
[LEFT]if v-redirect then
do:
run mywebspeedfiles/redirect.html?name=joe&id=333.
return.
end.[/LEFT]
So if you want to do a redirect and pass values to the page javascript or headers will work better.​


By the way this example that you posted shown below is using run to call a procedure. What i showed above is not really the same thing as calling a procedure.​


Hi WebGuy,

Run mypage.html does work, but as you say it cannot contain http vars.

The trouble using run statement is that it run the page target inside the page which is invoking it.

This behavior create html conflicts, let me show what happens :

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- E4GL Disabled: meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" --> 
<title>Update Region Tax Information</title>
</head>
 <link rel="stylesheet" type="text/css" href="/css/estilo.css"> 
 <script language="JavaScript" src="/js/il_tabla.js"></script>
 <BODY>
<FORM METHOD="get" name="forma1">
        <input type="hidden" name="lirowId"     value="0x000000000000476e">
        <input type="hidden" name="user"        value="0x00000000000006f7">
        <input type="hidden" name="funcion"     value="400">
        <input type="hidden" name="perfil"      value="0x0000000000088350">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>  
<!-- E4GL Disabled: meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" -->
<title>Display and Search Region Taxes</title>
<script language="JavaScript" src="/js/utilerias.js"></script>
<link rel="stylesheet" type="text/css" href="/css/estilo.css"/>
</head>
<body onload="document.form1.ValueSearch.focus();">
<FORM name="form1" method="post">   
<TABLE align="right">
The page which invoke generate it´s own html headers and when run "run index.html" then the target page is included on the first one creating once again the html code.

I've tried with the Meta tag method and Headers but doesn't work.
header method writes "Location: index.html" instead take me to the index.html (I made sure the header is the first line on my code).

I think headers could be the answer im looking for, but i don't know how to use them properly.

If you got a better sample o could explain me how them works would be amazing.

Thank you so much for your time.
Best Regards!

Israel M;
 

webguy

Member
run will work but it sounds like you are using frames? If you are using frames there is no way to specify the target using progress run statement(html frames char people).

Im not sure what you are trying to do. The code you posted I assume is the output. Perhaps you can post the code for your html and speedscript so I can see how you are trying to invoke the redirect. What you are trying to do is pretty basic. I cant see any reason why it cant work. Maybe you are confusing redirect (to a completely different page) versus refresh or reloading the same page?

By the way this is using a headers with speedscript to do a redirect.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="speedscript">
procedure output-headers:
output-http-header("status","302").
output-http-header("location","http://www.progress.com").
output-http-header("","").
end procedure.
</script>
</head>
</body>
</html>

redirect with webspeed
 

israelm

New Member
run will work but it sounds like you are using frames? If you are using frames there is no way to specify the target using progress run statement(html frames char people).


Hi Webguy,

This is the code im using :

HTML:
<script    language="SpeedScript">

  /* If delete confirmed */

   IF GET-VALUE("delConfirmed") = "true" THEN DO:
  /* Here delete Statements */
 
   output-http-header("status","302").
   output-http-header("location","index.html").
   output-http-header("","").
   
   END.
</script>

I am using frames on my application. i apologize don't mention it before but i thought it would work even on frames properly.
Then i guess the only way i have to perform the redirection is taking advantage of another language such as JS. (document.location="").

This way i take to redirect with webspeed using frames, i hope can be useful for someone that have the same trouble. (Using JavaScript)

HTML:
<script    language="SpeedScript">

  /* If delete confirmed */

   IF GET-VALUE("delConfirmed") = "true" THEN DO:
  /* Here delete Statements */

</script>

<script    language="javaScript">
 // Redirecting after perform an action.
 location.href="myTargetPage.html?var1=1&var2=2&var3=3";
</script>

<script    language="SpeedScript">
  
  LEAVE. /*Stop Program Execution*/
  END.

  /* deletion routine finished */
</script>
I wouldn't like to use JS but so far is the only way i have to redirect under frames and pass variables via http.

Thank you for your time, i really appreciate it.
Best Regards!

Israel M.
 
Top