WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

UDF - UDS Library
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Variables inside and outside a UDF

Keywords:   Variables inside and outside a UDF global variables local variables

Question:

I am having trouble with the use of variables. I can use any variable outside the UDF in subroutines that exist outside the UDF and any variable within the UDF works OK within, but I cant seem ot pass the values between. In specific I am loading a droplist box with the selection list and a set of Arrays outside the UDF and the variables maintain the values but I cant use the values in a call to the UDF after a form action has occurred.

Answer:

Variables within the UDF are available only with in the UDF, unless passed to the UDF as a parameter.

You can pass arrays to user-defined functions, and you can return arrays with the Return command.When you pass an array name (ie, not an array element) as a parameter to a function, the array gets passed "by reference". That is, the function receives a pointer to the array, and is therefore able to make changes to it "in place".

In contrast, passing an array element (ie, with a subscript) to a function is like passing a regular string or integer parameter to a function -- it gets passed "by value". Ie, the function receives the value of the array element, but is not able to modify the array itself.


Article ID:   W15329
File Created: 2002:09:05:13:51:20
Last Updated: 2002:09:05:13:51:20