help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help using cgi-bin package for Octave


From: Alexander Barth
Subject: Re: help using cgi-bin package for Octave
Date: Mon, 02 Sep 2013 10:42:51 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8

Dear Eduardo,

On 27/08/13 18:07, Eduardo D. da Costa wrote:
> Dear Alexander
>
> I have been trying to use the cgi-bin package for Octave you kindly
> made available at
> http://modb.oce.ulg.ac.be/mediawiki/index.php/CGI_programming_with_Octave.
>
> I tried with success your "Hello word".
>
> I am trying now to do this exercise:
> 1) ask for a number  X
> 2) a) if the number is odd then say in a clean new page "The number X is odd"
>     b) if the number is even then say in a clean new page "The number X is 
> even"
>     c) if neither, say, in a clean new page, "Please use an integer"
> and allow  redoing the all thing again.
>
> I have tried different things and could not  get this working.
> Is it impossible?
> If it is not impossible could you please help me by telling me how to do it?
This is very well possible.
* first check if the parameter "number" is provided (using this
http://octave.sourceforge.net/cgi/function/@cgi/has.html)
* if not, return a page asking to provide one
* if yes, try to parse the variable using str2double (not str2num because 
str2num uses the eval
function)
* if parsing failed or if the variable is not an integer return the page 
"Please use an integer"
* use function mod(x,2) to see if the variable is odd or even and return a 
corresponding page.

All pages should include a link to your cgi script allowing to enter a new 
number.

Such a web-page would be the first step. If you get more familiar with 
web-programming, it is better
not to mix too much HTML code and octave code (or any other server-side code). 
You can use
XMLHttpRequest (http://en.wikipedia.org/wiki/XMLHttpRequest) to trigger from 
JavaScript in your
web-page the octave code on your server, return the result in JSON (or XML), 
and update your
web-page using JavaScript (without a full refresh; this programming model is 
sometimes called AJAX).
I used this for instance in the following web-page:
http://data-assimilation.net/Tools/divand_demo/html/.

Please use in future the octave mailing list (in CC). Other users might ask 
themselves similar
questions.

Cheers,
Alex



>
> Your help will be greatly appreciated.
>
> Thank you a lot in advance,
> Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]