Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return a none Public Variable
Message
From
10/11/2001 13:20:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/11/2001 12:52:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00580162
Message ID:
00580167
Views:
17
>I have code that takes a drawing number and figures out witch folder it resids in. I go trhough a few do cases for this. I have several places where this code is used so I wanted to create it in a program or procedure that all places could use it. So I send my drawing number as a parameter and my conventional way would be to set a Public variable and then back in my calling program use that result. But now with what you and Jim have taught me I thought I could create a custom Property in my calling form, sent that as a second parameter and have the prog assign a value to it. But I can't get the property to respond.

OK. Let me try to show with a form. It'll be in code but you could replicate visually :
oForm = createobject('myForm')
oForm.Show
Read events

Define class myForm as Form
  MyProperty = 0 && This is what you previously used as global
  Add object text1 as textbox
  Add object command1 as commandbutton with Top = 50
  Procedure init
  If !'MYPROCSTORE.PRG'$set('PROCEDURE') && Function is in MYPROCSTORE.PRG
    Set procedure to myprocstore additive
  Endif
Endproc
  Procedure GetResult && A custom method
  Thisform.text1.value = myFunction(thisform.MyProperty)
Endproc
  Procedure queryunload
  Clear events
Endproc
  Procedure command1.click
  Thisform.MyProperty = 25 && Any method in form might have set this
  Thisform.GetResult() && Do rest via custom form method
Endproc
Enddefine
*myprocstore.prg
function MultiplyBy5
lparameters tnValue
return tnValue*5

function myFunction
lparameters tnValue
local lcRetVal
do case
   case tnValue % 2 = 0
   	return 'Even'
   case tnValue < 25
    return 'A small number'
   case tnValue > 2000
   	return 'W2K rocks'
   otherwise
    return "I don't know what to say"
endcase
Actually I would suggest using custom objects for frequently used methods by many other objects like a form. Now for the moment just try if this helps.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform