Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Private declared in main program are not visible...
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00514726
Message ID:
00514735
Views:
9
>>Hi everyone,
>>
>>I have these lines at the top of main program of my application:
>>
>>private pcTempDrive, FieldValPrefix, TableValPrefix && Make them visible everywhere in the project
>>pcTempDrive=justdrive(sys(2023)) && VFP Temp drive
>>FieldValPrefix ='IIF(VARTYPE(oValid)#"O".OR.Ovalid.nlocked<0,.F.,IIF(Ovalid.nlocked=0,.T.,))'
>>TableValPrefix ='IIF(VARTYPE(oValid)#"O".OR.Ovalid.nlocked<0,.F.,IIF(Ovalid.nlocked=0,.T.,))'
>>
>>Main program calls form (do form ...), this form calls a function. In this function I got an error, that these variables are not defined. Could somebody give me a clue, why is what?
>>
>>I can add a check, no problem, but just want to understand the reason for this behavior.
>
>Does a variable exist if it was never initialized?

It chockes on TableValPrefix variable, which is definitely initialized in the main program.

This is the full text of main program:
************************************************************
* AUTHOR     : Nadya Nosonovsky
* DESC          : Main program for DataDict
* PARAMETER     : tcRunMode, tcDBCName, tcProcess, tcInputTable
* CREATED     : 06/03/1999
* MODIFIED  : Nadya Nosonovsky 05/17/2001 01:02:30 PM
* RETURNS     :
*---------------------------------------------------------------------
lparameters tcRunMode, tcDBCName, tcProcess, tcInputTable
* tcRunMode - Various modes in which DataDict could be invoked - optional
* tcNewDBC  - Name of the DBC, which should be created (Clone or Generare mode) - optional
* tcProcess - ParcelProc
* tcInputTable - Name of the table to use in clone
*
=launch() &amp;&amp; Set environment
private pcTempDrive, FieldValPrefix, TableValPrefix &amp;&amp; Make them visible everywhere in the project
pcTempDrive=justdrive(sys(2023)) &amp;&amp; VFP Temp drive
FieldValPrefix ='IIF(VARTYPE(oValid)#"O".OR.Ovalid.nlocked&lt;0,.F.,IIF(Ovalid.nlocked=0,.T.,&lt;FUNCTION CALL HERE&gt;))'
TableValPrefix ='IIF(VARTYPE(oValid)#"O".OR.Ovalid.nlocked&lt;0,.F.,IIF(Ovalid.nlocked=0,.T.,&lt;FUNCTION CALL HERE&gt;))'
local lnParams, llReturn, lloJCExists
store .t. to llReturn, llSetStatus
lloJCExists=vartype(oJC)="O"
lnParams=pcount() &amp;&amp; Number of parameters
**** Validate parameter first
if m.lnParams=1 and vartype(m.tcRunMode)&lt;&gt;'C' &amp;&amp; Something is wrong
     if m.lloJCExists
          oJC.CurAppStat="I"
     endif
     return .f. &amp;&amp; quiet fail
endif
if m.lnParams&gt;1 and (vartype(m.tcRunMode)&lt;&gt;'C' or vartype(m.tcDBCName)&lt;&gt;'C') &amp;&amp; Something is wrong
     if m.lloJCExists
          oJC.CurAppStat="I"
     endif
     return .f. &amp;&amp; quiet fail
endif
if m.lnParams&gt;0
     tcRunMode=upper(m.tcRunMode)
endif
if m.lnParams&gt;1
     tcDBCName=upper(m.tcDBCName)
endif
if !empty(m.tcRunMode) and inlist(m.tcRunMode,"RUN","REINDEX","PACK","CLONE")
     ** Create private DS
    local loPrivateDS
       if not ('privatedsclass') $ lower(set('procedure'))
       set procedure to PrivateDSClass additive
    endif
   loPrivateDS=newobject("DataDictDS","DataDictDS.prg")
   llReturn=loPrivateDS.DoFunction(m.tcRunMode, m.tcDBCName, m.tcProcess, m.tcInputTable)
   release loPrivateDS
   use in select('IndxDict')
   use in select('DataDict')
   use in select('ValCalls')
   if m.lloJCExists and empty(oJC.CurAppStat)
         oJC.CurAppStat=iif(m.llReturn,"C","I")
   endif   
   release pcTempDrive, FieldValPrefix, TableValPrefix 
   return m.llReturn
endif
do case
case m.lnParams=0  &amp;&amp; Default invokation
     do form DataDictionary  &amp;&amp; Main user form come without parameters
case m.tcRunMode='DATADICT'
     do form DataDictionary  &amp;&amp; Main user form come without parameters
case m.tcRunMode="LKUPS"
     do form LkupDictionary
*--------------------------------------------------------------------------
* -- PKP:  Added Run Mode = 'METHODS' for the methods Form
*--------------------------------------------------------------------------
case m.tcRunMode="METHODS"
     do form Methods
case m.tcRunMode="SUPP"
     do form SuppDictionary
otherwise
* There should not be otherwise!
     =messagebox('Run mode '+m.tcRunMode+' not supported!',48,'Unsupported parameter')
     llReturn=.f.
endcase
release pcTempDrive, FieldValPrefix, TableValPrefix 
return m.llReturn
I run DataDict without parameters, so it shows the main form (non-modal). Then I click on Update button, which calls a simple modal form to choose databases to update. I pick one and it runs a program called ModifyStructure. This program in turn calls another program called modify_structure. This program reports about missing variable TableValPrefix.

Note, that commenting out release statement at the bottom didn't fix the problem.

>Could it happen that SYS(2023) not return anything and the IIF never get back anything to set the variable to.
>
>Also your Function Call Here is not showing up as it is being interpreted as HTML.

I didn't show it.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform