WMLScript/Basic Programming Help

Associate
Joined
20 Jun 2004
Posts
988
Location
Manchester
I'm doing a very basic WAP 'application' for one of my modules at university but i keep coming up against a brick wall.

Basically, this is my WML code

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="card1" title="Password Generator">

<do type="accept" label="Generate">
<go href="passscript.wmls#generate('$(passlength)')"/>
</do>


<p align="center">
<img src="title.gif" alt="Title" align="middle"/>
<br/>
<small>This program is designed<br/>
to create a pseudo-random<br/>
passcode based on your<br/>
requested length
<br/>
<br/>
<br/>
Please input the length you would like your password<br/></small>
<input size="10" format="*M" name="passlength" title="Password Length:"/>
<br/>

<b>Result = $(generatedcode)<br/></b>

</p>

</card>

</wml>

Basically, the user specifies a length they want a 'passcode', then this number is passed through to the WMLScript file that calculates how many times to run a 'for' loop, inside that loop i basically wanted it to generate a random number between 1-9 and then add it onto an existing string, so in the end you'd have X amount of numbers converted to a string and then tacked onto the end of the string, then you get a passcode, but i keep coming up with a 'Function Argument Number Mismatch' when im writing it in the Nokia Mobile Internet Toolkit and i just for the life of me cant find what this means or understand what it means.

Heres my WMLScript, could anyone please tell me what im doing wrong, because i'm terrible at this and its due tomorrow. I will be much thankful.

Code:
extern function generate (passlength) {

var loopcounter = Lang.parseInt(passlength);
var generatedcode = "";

for (var counter=0; counter < loopcounter; counter++)

{
var tempvalue = 0;
tempvalue = String.toString(Lang.random(9));
generatedcode = generatedcode + tempvalue;
}

WMLBrowser.setVar(generatedcode);
WMLBrowser.refresh();

}
 
Back
Top Bottom