Procedure

Q:
Say I have a function that returns an array (or datetime, or whatever), if that function fails I want to return null and then check for that null (as you can/would in C#), something like the code below. What are the rules for this in lianja

Code:
function test(ok)
  if (ok)
    return array()
  else
    return null
  endif
endfunc

x = test(.F.)
if x=null
  //The function failed
endif

A:

Code:
function test(ok)
  if (ok)
    return array()
else
    return .null.
  endif
endfunc

x = test(.F.)
if isnull(x)
  //The function failed
endif

Q:
it looks like ‘tcPassedIn1’ is local to ‘Test1’ and not private:

Code:
proc page1_section2_field2_click()       
local lcTest
lcTest = "Original String"
        Test1(lcTest)
MessageBox(lcTest, 0)
endproc

proc Test1(tcPassedIn1)
tcPassedIn1 = "Var not overwritten"
Test2(tcPassedIn1)
MessageBox(tcPassedIn1, 0)
endproc

proc Test2(tcPassedIn2)
tcPassedIn2 = "Var overwritten"
endproc

A:
Parameters in the proc declaration are local as you point out.
This is not standard VFP, it’s another useful extension that reduces typing.
No need for lparameters… statement



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s