Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
#DEFINE - Why?
Message
From
06/04/2008 05:26:14
 
 
To
30/03/2008 19:48:52
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01306848
Message ID:
01308491
Views:
10
>What is the simplest explanation as to why these are needed? Why not just set regular variable values? So what if they are constant and don't change?

Haven't seen at all of the discussion. But some things you can't do with vars is:

-conditional compiling
#Define DEBUG .T.

#If DEBUG
    goApp.logsomething()  
#Endif
If you set DEBUG .F. the line isn't compiled into the exe at all.
So you may exclude function/code/builders/helptools from the final exe. Think about recompiling options, this way you can have your hands on some of your source code not by encrypting it as safe as that may be, but by simply not including that code portions.

-expressions
#Define FindFirst Sys(2000,SKELETON)
#Define FindNext  Sys(2000,SKELETON,1)

Local lcSkeleton
lcSekelton = "c:\*.*"
#Define SKELETON lcSkeleton
? FindFirst
? FindNext
? FindNext
Even overload functions
#Define File myFile

Function myFile(lcFilename,lnFlags)
   If !Directory(justdrive(lcFilename))
      Return .F.
   Endif

   If !Directory(justpath(lcFilename))
      Return .F.
   Endif

   If pcount()=1
      return File(lcFilename)
   Endif
   return File(lcFilename,lnFlags)
Endfunc
This for example once saved my day as a fileserver was misconfigured to need a timeout of 30 seconds before returning .F., if a requested file name didn't exist, while checks für drives and directories didn't have that performance hit.

And even those simple unchanging variable similarity is good, as you can simple drag&drop constant definitions for OLE classes in the object browser, eg for Office constants.

Bye, Olaf.
Previous
Reply
Map
View

Click here to load this message in the networking platform