Vitus Computer Consulting, Inc. Visual FoxPro Tips

Below are some things we've run across while developing in VFP. Some are really basic, but they cost us hours of debugging and trouble shooting, so we hope to save you the trouble. If you have any suggestions, or tips of your own, we'd love to have them.
Using CurDir() to return the path
When to use 'm.'
Using the NAME clause

Using CurDir() to return the path

One way to return the path of the executable is : path= SYS(5) + CurDir(). This will work fine, but if you are running the app under NT, make sure the Working Directory in the properties of the icon (in File Manager) is set to the application's direcory. CurDir() seems to return the Working Directory, not the true current directory.
Index

When to use 'm.'

I have noticed some confusion in the newsgroups about using the 'm.' prefix. Using 'm.' is only needed if you have a memory variable with the same name as a field in a currently open table or view. One scenerio for this would be if you tend to use SCATTER MEMVAR and GATHER MEMVAR. You need to reference the memory variables as m.FieldName, especially if you move the record pointer in your code while referencing memory variables. Using the 'm.' prefix will prodce a slight performance hit, but for all intensvie purposes, this is not important (a few seconds more for total execution time if you reference EVERY memory variable in a large app with 'm.')
Index

Using the NAME clause

This is a good one that I have just learned. It is quite basic really, but I have noticed that I wasn't the only one kept in the dark about this clause. If you want to reference one form from another, run the forms using : DO FORM FileName NAME FormName. Then, reference the properties like : FormName1.Caption = FormName2.Caption
Index







Vitus@Vitus.com