2009-06-15 18:00:24

Hi,
I was wondering if anyone knew which function I had to use to create a random integer between 1 and a certain number that I could define? Thank you.

skype name: techluver
Feel free to add me.

2009-06-17 15:07:18

Check for a "rand" or "random" function in the list, but if there isn't any "rand" or "random" function in  Ctrl+I function list, it's probably impossible to do it in jaws script.

There are 10 kinds of people : those who know binary, and those who don't.

2011-03-07 02:39:15

Howdy,

I need help on JAWS scripting, too. Since I am a newbie on JAWS scripting, you may find my following script so tedious. Anyway,let me tell my issue that I am currently having.

I attempted to write a script that will do an arithmetic operation, and present the result in a dialog box but what I got is a compilation error. Here is the script that I mentioned:

Script Test ()
VAR
int X,
int Y,
int Z
X=Y+Z
Y=155*120
Z=25
ExMessageBox ("The value that you are looking for is", SayInteger (Z), "FYI!", MB_OK)
EndScript

Where am I doing wrong? Any help would be greatly appreciated.

Regards,
SplendidFault

Standing by the window, eyes upon the moon,
Hoping that the memory will leave her spirit soon.

2011-03-11 21:36:13

SplendidFault wrote:

Where am I doing wrong? Any help would be greatly appreciated.

Hello,

Lets look at the issues one by one.
First compile error I get, "unknown variable mb_ok".

This is because the MB_Ok item is part of the FS standard libraries. You need to include them, usually at the top of your script file.

include "hjconst.jsh"
include "hjglobal.jsh"

Next error: " Function ExMessageBox requires 3 parameters not 4".

This is because you've got a comma in what should be the first parameter, you need to have the value that you are looking for, quote, pplus. Instead of quote then a comma.

next error: " Parameter 1 to Function ExMessageBox  should be of type string not int"

This is because you are trying to use a say function within a message box.  The say functions output text to the synthesizer.  TO display a number inside a message box you need to use the IntToString function in place of SayInteger.

With the above changes, compilation succeeds.  running the script, I get: "FYI! Dialog
The value that you are looking for is25
OKButton"

My complete code is below:

include "hjconst.jsh"
include "hjglobal.jsh"
Script Test ()
VAR
int X,
int Y,
int Z
X=Y+Z
Y=155*120
Z=25
ExMessageBox ("The value that you are looking for is"+ intToString(Z), "FYI!", MB_OK)
EndScript

2011-03-12 02:48:37

Hello,

A very perfect explaination! Many thanks for this nice touch. Now, with your aid, this is the last version of my script. I added a space after 'is', and put a period sign just end of the sentence. It now gives the result in a more natural way. Compile and see:

include "HJConst.jsh"
include "HJGlobal.jsh"

Script Test ()
VAR
int X,
int Y,
int Z
X=Y+Z
Y=155*120
Z=25
ExMessageBox ("The value that you are looking for is"+" "+IntToString (Z)+".", "Important Information!", MB_OK)
EndScript

Regards,
SplendidFault

Standing by the window, eyes upon the moon,
Hoping that the memory will leave her spirit soon.

2011-03-12 12:15:19

that's perfect.

One thing to note is that x will -=0 in this script, because when you wrote X=Y+Z, Y and Z were both 0.  you only changed their values after you assigned X.


If you need any further help, please ask; I am happy to oblige.

2011-03-12 13:09:29

Let's see if I figured out your statement about necessity of assigning a value for X first:

Script Test ()
VAR
int X,
int Y,
int Z
X=15
Y=155*120
Z=25
let X=Y+Z
ExMessageBox ("The value that you are looking for is"+" "+IntToString (X)+".", "Important Information!", MB_OK)
EndScript

Sincerely yours,
SplendidFault

Standing by the window, eyes upon the moon,
Hoping that the memory will leave her spirit soon.

2011-03-12 14:06:55 (edited by cachondo 2011-03-12 14:08:57)

SplendidFault wrote:

Let's see if I figured out your statement about necessity of assigning a value for X first

No, not quite correct.

In your first script, you wrote:

X=Y+Z
Y=155*120
Z=25

If you output these, Z=25, Y=18600, and X=0.

X=0 because, when you wrote X=Y+Z, Y and Z both=0.

if you move the lines, so you had:

Y=155*120
Z=25
X=Y+Z

X now =465000.
y, 18600, multiplied by (*) Z, 25).

I hope this helps explain.

2011-03-12 17:08:49

Or to put it another way:
You set X equal to Y plus Z before you put anything into Y or Z. Think of it as like having a milk bottle, cereal container and bowl. You need to put milk in the bottle and cereal into the cereal box before you can use them to put anything into the bowl.

cx2
-----
To live by honour and to honour life, these are our greatest strengths and our best hopes.

2011-03-13 00:49:29

Nicely explained, thanks again. Now I feel like I should step into more complex scripting methods, like decision making, function calling etc.

Standing by the window, eyes upon the moon,
Hoping that the memory will leave her spirit soon.

2011-03-13 01:10:39

JAWS scripting is a strange language.  I'd advise not learning it, just to learn to program - there are languages more suited to that.

if you have an application to script, though, or you want to write a script as a JAWS plugin etc that might be a good way to start.

keep us posted!