Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a value without using global variable 4

Status
Not open for further replies.

SBTBILL

Programmer
May 1, 2000
515
0
0
US
do form with param1, param2, etc

in the init of the form

parameter param1, param2, etc

store param1 to thisform.param1
store param2 to thisform.param2

Bill Couture
http:\\
 
Hi,
I know I am doing this inefficently and I need to know what I should be doing.
I have set up a form that uses a view with parameters for year, period, and user_id.
1. The user logs into the application with his id/password.
2. If the user fits a certain type (from user table) the form with the view runs and displays the appropriate view data. Otherwise it displays a menu screen.
I tried to initialize the variables for the year, period and user_id in the INIT of the forms Data Environment, but as soon as I run the application it prompts for them, before the form displays and whether or not the form is required.
I created properties within the form to hold the values and then created a program that runs as soon as the app opens. When I tried to init the values in the form it didnt work because the form has not been opened yet, and may not need to be.
I have now assigned the values to global variables and the app does what it should do. How should I be doing this??
 
GarryC

You could use a global custom class that would hold these values the whole time the application is running.
Code:
PUBLIC goGloBal
goGlobal = CREATEOBJECT("oGloBal")
DEFINE CLASS oglobal AS custom
	Name = "oglobal"
	cYear = ''
	cPeriod = ''
	nUserid = 0
ENDDEFINE

And you would put this near the beginning of your main program. And this "goGlobal" class is available to use until you close that application. You can refer for example in the login screen valid of the userid textbox to store the values.
Code:
Store this.value to goGlobal.UserId
Store alltrim(str(year(date()))) to goGloBal.cYear
etc...


And in the init of your other forms you can check the values of the different properties of goGlobal
Code:
IF goGlobal.cYear = "2003"
  && do something
ELSE
  && Do something else
ENDIF

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Thanks guys. Can you also tell me this. This application is installed on a number of machines, all pointing to a common mapped drive for data. Is the global custom class, or for that matter a global variable, affected by other users running the same application installed on their machines but pointing to the common data. Each machine has its own copy of the app.
I know this is basic question but I have never networked an app before, everything I have written has been stand alone.
 
Thanks guys. Can you also tell me this. This application is installed on a number of machines, all pointing to a common mapped drive for data. Is the global custom class, or for that matter a global variable, affected by other users running the same application installed on their machines but pointing to the common data. Each machine has its own copy of the app.
I know this is basic question but I have never networked an app before, everything I have written has been stand alone.


If you are using the global class, each time the application starts, it will create a new instance of the class, so you shouldn't have any trouble with that. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Have you thought of creating a table that holds the memory varables and the drive letter/directory mappings.

If the dbf was on the local machine, then every computer can have the drive mappings that are different then the computer next to it, and the memvars can be saved at will for all programs to use?
David W. Grewe
Dave@internationalbid.com
 
Thanks guys,
These are all great suggestions.
I though about the table idea earlier but decided against it. The reason being that this is not an intensly used app and I may decide to run off the server rather than on individual work stations. I want to keep as much located in one place to make it easier to maintain. The system this supports is being enchanced and thus this app will need many upgrades over the next 12 months.
I am passing parameters to the form at the moment and this works fine. It has occured to me however that future development may cause problems as some of the variables I may want to use in enhancements will only be available immediatly the app starts and then be changed.
The global custom class will handle current and future needs so I will go with this.

Appreciated your responses greatly.
Garry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top