Variable scope between forms


#1

How does one declare a variable to be global to all forms in a project? Tried declaring variable at project level, not using a ‘var’ (using JS) to no avail. Ideas?


#2

If you declare a variable outside of any function, it becomes global.

So, you could do this:

var myGlobal = 'some string';
... the rest of the code for your project

Note that polluting the global namespace is generally frowned on.


#3

What’s the best practice for passing multiple variables back from a function? I know it’s easy to pass several values to a function ie: calc_function (var1, var2, var3). But I need to receive back several variables from the function.
Thanks,
Malcolm


#4

In BASIC or JavaScript?


#5

Thanks! It is JavaScript.

Cindy


#6

Here’s a good article showing a number of ways to do this:


#7

Thanks! I’ll pass this on to my students. Much appreciated.

Cindy