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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters to a program

Status
Not open for further replies.

pilrchr

Programmer
Joined
Aug 11, 2003
Messages
7
Location
CA
Hello there, thanks to take the time to read my problem...
Here it is...lets say i have few tables, and in each table i got a numeric feild, but they don't have the same name (like a PK in Oracle).
I.E : 1 table for my friends and 1 table for my family members. Each friend and member have a number to identify them. In my friends table, that feild is called NU and in my family members table, that field is called NA.
I made a program to reset the NU field automaticly, so if i loose a friend, the numbers still follow from 1 to x (x=end).
But i do not want to make few times the same program(if i had 30 tables) and just change the NU, by NA, or anything else...So i though i could pass an integer to my program, do the incrementation with that integer, and then return it to the right table in the right field. I know this is possible in C, but i do not know how to do it in FoxPro 2.0.
Is there anyone that can give my help?
I would really appreciate it.
Thanks.
 
If you know PK's in Oracle, then you know that it's NEVER a good idea to attach any significance to it's value. This should be created once and never changed - otherwise maintaing referential integrity between the tables can get complicated. Instead consider a separate field to ID your individuals.

FP 2.0 like all version of FoxPro can pass parameters to .PRGs, .APPs or .EXEs. You'll have provide a a bit more information to understand what you really want to accomplish. e.g. Table fields - names, types and sizes. Is this something only you are using? Are you working strictly in the Development Environment? Do you use projects to create .APPs and/or .EXEs?

Rick
 
First of all, thank to answer me rgbean.
I know Oracle, and the question i asked is related to my dad's project. 'm asking for him cause he do not have Internet. I'll get more informations and i'll post them as soon as possible.

Thank again.
 
To pass parameter(s) to a program just follow this pattern:

Code:
DO MyProg WITH "5"  && passes the string value of 5
DO MyProg WITH 5  && passes the numeric value of 5
DO MyProg WITH cVar  && passes your string variable
DO MyProg WITH nVar  && passes your numeric variable

Also you can pass several different parameters in this manner, just be sure the program expects the parameters and their respective data types.

Code:
DO MyProg WITH "John", "Smith", 34, {05/06/1970}, cAddr

Then withing the destination program add the PARAMETERS line at the beginning of the code but after the PROCEDURE name:

Code:
PROCEDURE MyProg
PARAMETERS in_fname, in_lname, in_age, in_bdate, in_addr

If any of the parameters names are already in existence when this program starts, the original values are "hidden" since within and below this program level these parameters are views as PRIVATE variables. When the program exits, the parameter data is discarded and the original values are restored.

Parameters, if string type, cannot be more than 1024 characters long in FoxPro. Visual FoxPro allows longer strings as parameters.

If you make your own user-defined functions, then there are similarities but also a few differences. These UDFs look similar to the FoxPro functions provided as part of the program languuage and can return a value when completed. Also, some parameters can be passed by reference, meaning that if you change them in the called program, then it is still changed when it completes. There is a SET command that alters the default behavior. Check the manual...
 
Ok, here's what he told me..he doesn't use projects.
He has the prog to modify the NU field. All he wants is to make only one program that will modify any numerical feild whatever they're called NU, NA, NO or NV. Let say those fields are all in the same table. I know it's not a good way to have multiple feild for the same purpose, but he wants it like that.
If you could give me a way to make only one prog to increment a numeric field whatever the name of the field is it would be great.

Thanks again bud.
 
Thnaks dbMark,

Ok, now i have the way to work with a variable in my prog. Once i got the value changed, how do i return it to it's own table?
 
If you've passed the field name in as a parameter then this should work. Here are the basic commands...

Code:
PROCEDURE MyProg
PARAMETERS in_fldname, in_value
REPLACE &in_fldname WITH in_value
 
Thanks again for the advices guys. I'll try this week-end and give you feedback of what will be going on...Have a nice day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top