Visual FoxPro Tips

      Covers Visual FoxPro Verison 3 and Visual FoxPro Version 5

      In Association with Amazon.com
      In Affiliation with Beyond.com
      Index...
      [Top][Bottom]

      Using the Path specified in the Applications Shortcut...
      Setting the Path to the Database files using the Shortcut's Start in: setting...
      Context Specific Menu... Hint: Right Click
      Displaying Property Description on Properties for the Controls...

      How I get Help for Visual FoxPro Programming questions...

      When I try to exit my Visual FoxPro application, I get the following message "Cannot quit Visual FoxPro". How do I fix this?...
      List of Code Characters for the @...GET FUNCTION and PICTURE...
      Visual FoxPro Interactive Mode: I hit Alt+F4 or clicked on the Close Box and Lost a lot of Work. How do I stop this?...

      Create a Julian Date (YJJJ and KYJJJ) from a Date (MM/DD/YYYY) (Year 2000 Compatible)...
      Create a Date (MM/DD/YYYY) from a Julian Date (YJJJ and KYJJJ) (Year 2000 Compatible)...
      Grid: How do I Add (Delete) a column(s) to an existing Grid Control?...
      List of Code Characters for the FORMAT Attribute...

      How do I Cascade the MDI Child Windows in my application?...
      How do I Enable/Disable Menu options?...
      How do I Print the contents of an Edit Box from the File | Print?...
      How do I store a BITMAP Copy of my Applicaiton (or Full Screen) in the Windows Clipboard?...

      Quick/Short Tips and Tricks... (Little explaination and NO Frills!)
      Status line, Quick Menu, Close All, Help, Transform(), Report Designer: Preview
      Tips and Tricks about using Microsoft's Technical Support Knowledge Base...
      How do I add an Open Windows List to the end of my Windows Menu?...
      How do I Arrange the Minimized MDI Child Windows in my application?...
      Report Designer: How do I change the text of a label (not the sticky ones<G>) control?...

      How to Index Descending in an Ascending Index or visa versa...
      How do I pass command line arguments to my application?...
      List of Selected Microsoft Knowledge Base Articles... (Updated!)
      Microsoft's FTP (Download) Software Library...
      How to Auto-Cascade MDI Child Windows...

      These Tips and Tricks come from years of experience, from help that I've gotten from others, from books and other places (such as Compuserve). I've tried to identify and give credit to the people who have helped me along the way. Sadly, I haven't been about to identify everyone -- but I have tried.

      Most times the Tips or Tricks come from my own experience. If I have trouble with something or find something useful -- I figure that someone else might benifit.

      I hope that you find these Tips and Tricks useful. I refer to them from time to time.

      Send me your Visual FoxPro Tips, Tricks or Questions...

      Visual FoxPro Resources | Visual FoxPro Book Suggestions
      Microsoft Technical Support Knowledge Base


      [Index][Next] 01 [Prev][Top][Bottom]
      Using the Path specified in the Applications Shortcut...

      The path of interest is under the "Shortcut" tab of the Shortcut's Properties dialog. The "Start in:" text box contains the default path that Windows will establish when the Shortcut/Application is run.

      At the time of startup, SYS(5) + SYS(2003) can be used to determine what the path is that was set in the "Start in:" field. SYS(5) is the default drive with colon and SYS(2003) is the default path, without a trailing "\" unless the path is the root directory.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/09/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 02 [Prev][Top][Bottom]
      Setting the Path to the Database files using the Shortcut's "Start in:" setting...

      The path of interest is under the "Shortcut" tab of the Shortcut's Properties dialog. The "Start in:" text box contains the default path that Windows will establish when the Shortcut/Application is run.

      The "SET PATH TO" command is used to set the default path that FoxPro should use to find the database files. The path can be set to a subdirectory under the path specified in the Application's Shortcut's "Start in:" field by,

      SET PATH TO SYS(5) + SYS(2003) + "\DBF\"

      Where SYS(5) is the default drive with colon and SYS(2003) is the default path, without a trailing "\" unless the path is the root directory. "\DBF\" can be a hardcoded string, as above, or a variable containing the path with the leading and trainig "\".

      If you think that your user might designate a root directory, then you need to check the return value from SYS(2003) to see if the last character is a "\". This can be done with if(RIGHT(sys(2003),1) = "\") then...endif.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/09/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 03 [Prev][Top][Bottom]
      Context Specific Menu... Hint: Right Click

      As in Windows/95, RIGHT Clicking on an object -- most likely will bring up a Context Specific Menu.

      When in doubt -- Right Click! -- to find out

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/09/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 04 [Prev][Top][Bottom]
      Future


      [Index][Next] 05 [Prev][Top][Bottom]
      Displaying "Property Description" on Properties for the Controls...

      When you're configuring a control (Grid, TextBox, Command Button, etc) there is a Properties Display Dialog. This Dialog is used to set the attritributes for the control. The Dialog can be configured to display a short description of the current Property (Class, Delete event, ZOrder, etc). This is done by RIGHT Clicking on the Title bar "Properties - ..." and checking the "Properties Descriptions". Other attributes that you can set are... "Always on top", "Non-Default Properties only", Font size (small, medium, large) and get some Help.

      "Always on top" in VFP/3 is set by clicking on the icon that looks like a thumb tack or push pin.

      Platform: Windows/95
      FoxPro: VFP/5
      Recorded: 06/09/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 06 [Prev][Top][Bottom]
      Future


      [Index][Next] 07 [Prev][Top][Bottom]
      Future


      [Index][Next] 08 [Prev][Top][Bottom]
      Future


      [Index][Next] 09 [Prev][Top][Bottom]
      Future


      [Index][Next] 10 [Prev][Top][Bottom]
      How I get Help for Visual FoxPro Programming questions...
      (Generally, this is how I get help for other languages like ... Visual Basic, Visual C/C++, PowerBuilder, Java, JavaScript, HTML, etc)

      FoxPro Help
      • Use the online FoxPro Help.
      • Look at the examples that are given for the topic.
      • Highlight a word or phase in my code, that I have a question about and press F1 to bring up the help for the topic.
      • I run and review the samples programs that come with FoxPro.
      • Write small test programs to try out and prove a concept before I add the feature into your main programs.
      • Try things at the command line.
      • Get the latest version of Visual FoxPro.
      Compuserve VFOX

      Forum

      • Joined Compuserve and became and active member of the VFOX Forum and other forums (VBPFORUM, JAVAUSER, MSBASIC, etc) that interest me.
      • Read the messages that have been posted in the Forum.
      • Ask Questions, in the appropriate Message Area. Say thank you for any help that I receive.
      • Normally, I (you) get a reply to my questions within 24 hours. (No, guarantees -- but so far it works for me. Generally it is sooner than that.)
      • If I know the answer to a question someone else posts -- I Try and Help. You fell better, you will learn from the experience, make new friends and it's just the thing to do. If everyone Gives as well as Takes -- then the Forum will be better.
      • Scan the Forum Libraries for files that contain information I need; Book suggestions, Sample code. Demos, etc.
      • Download sample code, review it, modify it and learn from it.
      • Some forums have online Conferences with experts, authors, etc. Attending these is an effective way to spend your time and money. Normally, you will have the opportunity to talk (type<g>) with the speaker -- ask questions, make comments, etc.
      • (Please note, that my Compuserve Account is a personal account, ie, not paid for by my employer. I feel that this is a worthwild investment for me to help me keep up with the current trends in programming -- thus helping me do a better job and hopefully earn a better salary.)

      World Wide Web
      • Search the Web using Search Engines like Yahoo!
      • Create a list of key websites. Normally, I bookmark the site in Netscape and then transfer the Link to one of my Webpages
      • Created a web page of my own. You might consider a List of links or Tips and Tricks. Web sites grow as time goes on. Just start and see what happens.
      • Download sample code, review it, modify it and learn from it.
      • I have not spent much time in the News Groups, because I have not found them all that useful and I have not gotten the quick reliable replys to my questions and comments. Compuserve is my online resource for discussions.
      • I have a list of web sites that I find useful. You might take a look at these. They are found at Visual FoxPro Resources...
      • Write to the web site authors and let them know that I appreciate their work. Lots of us don't know if anyone is reading and benifitting from our work. Here's your chance ... eMail me!<g>
      Books
      • I buy and use books a lot. The online help and documentation are useful, but I can't curl up in my easy chair and read them.
      • Online Helps are not designed to be read from cover to cover
      • I have found Amazon.com to be a wonderful place to get books from. They service is Great! The prices are very good. The online information can be very useful. Sometimes I feel a need to go to a book store to look at the books. Sometimes, I go to the authors website or publisher's web sit to get more informaion.
      • Read Book Reviews.
      • Look at lists of books recommended by others. See my list at Visual FoxPro Book Suggestions...
      • Don't get too excited about the CDROMs and Disketts that are included with the books. Don't get me wrong. The source code from the book is valuable, but generally the extra software is a demo, crippled, old version or limited tme version. Generally, I go to the author's or developer's web site for the lastest and greatest.
      • Side note: If you are using a Shareware package and have not registered it -- Register it Today! It's the right thing to do.
      • Another side note: If you are using a Shareware or Freeware package -- write the author and let them know what you think.
      • Sometimes, I find it difficult to find Good solid, Under-the-cover, problem solving, in-depth, practical books. I keep looking. Send me your book suggestions
      • (Please note, I am an Amazon.com Associate. Which basically, means that I get some monies from any books that are purchased through links from my page. Prior to (and after) becoming an Amazon.com Associate, I purchased a lot of books. As it stands right now -- I will not be able to quite my day job because of all the revenue that I'm getting <g>)

        (Another note, I purchase most of the books I have myself, ie, my employer does not pay for them. I feel that this is a worthwild investment for me to help me do a better job and hopefully earn a better salary.)

      Magazines
      • I currently subscribe to FoxPro Advisor, Tamar E. Granor is the Editor, with contributors like Christof Lange, Ted Roche, Miriam Liskin, Rick Strahl and Malcolm C. Rubel.
      • I try an subscribe to magazines that provide good solid technical information and advice on practical day to day issues as well as keep me up to date with new inovations and features. Another magazine that I subscribe to is the Visual Basic Programmer's Journal, The Development Exchange - Fawcette Technical Publications, -- because it provides me with the information that I need.
      • Do you have any Magazines that you suggest?
      • There are online magazines, but I have generally not found the time to read them.
      Developer Conferences,

      Conferences,

      Trade Shows

      and Courses

      • I have attended these in the past. Currently, my employer is generally not funding these and they are too expensive for me to pay for personally.
      • The Best Developer's Conference that I attended was put on by Fox Software in 1990.
      • Trade Shows are good, but you're going to see what products are available for you to buy to meet your needs.
      • I have attended some very good courses in the past. Be sure that you find a course that is stong on content and not just an overview of the Visual FoxPro Interface.
      • Anybody can tell you how to use the Wizards or Builders, but not everyone can tell you how to go beyond them and make FoxPro do what you need it to do.
      • Find the Experts, the Hackers and the Go Beyond the Limits kinds of people. One book comes to mind ... Hacker's Guide to Visual FoxPro 3.0 by Tamar Granor and Ted Roche
      Personal Interaction
      • If you have someone or a group of people that you can talk to about Programming, by all means do it. People talking to each other is better than anything online or in a book.
      • Currently, I do not -- So, I rely on Compuserve, the Web and Books for getting help.
      Other Technical Resources
      • Microsoft's Knowledge Base - this is a great place to start your search for answers. If you don't start here, you should make sure that you keep it on your list of places to look.
      • Microsoft's TechNet is a resource that you need to subscribe to. It appears and sounds like a very valuable resource. From the description is sounds like it is well worth the price.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/10/1998 .. 06/29/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 11 [Prev][Top][Bottom]
      Future


      [Index][Next] 12 [Prev][Top][Bottom]
      When I try to exit my Visual FoxPro application, I get the following message "Cannot quit Visual FoxPro". How do I fix this?...

      Or another way to put this... Why doesn't the Close Box ([x] button) on the Window Title bar or the Alt+F4 key combination work?

      There is probably a READ EVENTS in effect and they need to be Cleared with a CLEAR EVENTS command, before your application can close. The best way to do this is by setting up an ON SHUTDOWN routine.

      The best way to set up an ON SHUTDOWN routine is to put in code that looks something like...

        ON SHUTDOWN DO pSHUTDOWN
        OKtoShutDown = .T.
      

      ...at the top of your application or add a custom property to your application class.

      The pSHUTDOWN Procedure, that is called ON SHUTDOWN, would look something like...

      PROCEDURE pSHUTDOWN
      IF (OKtoShutDown) THEN
        ** Close databases and do other cleanup
        CLOSE DATABASE
        CLOSE ALL
      
        ** Clear the READ EVENTS
        CLEAR EVENTS
      
        ** Clears the assignment to ON SHUTDOWN, Only important if ever run in
        ** Interactive Mode.
        ON SHUTDOWN TO
      
        ** Quit the application
        QUIT
      ELSE
        =MessageBox("Unable to exit the application", 48, "Application Busy...")
      ENDIF
      RETURN
      ** end-of-pSHUTDOWN
      

      If you don't want the user to exit the application, because something important is being done and should not be interrupted, then set OKtoShutDown to .F. If the user tries to exit the application, they will get a message saying that the application is busy and can not be exited at this time. Be sure to set OKtoShutDown to .T. or the user will never be able to exit.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/11/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 13 [Prev][Top][Bottom]
      Future


      [Index][Next] 14 [Prev][Top][Bottom]
      List of Code Characters for the @...GET FUNCTION and PICTURE...

      @ ... GET - Text Box Command

      FUNCTION cFormatCodes | PICTURE cFormatCodes

      Specifies a function code or picture code that determines how the text box output is displayed or printed. You can include the FUNCTION clause, the PICTURE clause, or both to create an editing mask. These clauses contain special codes that control how the memory variable, array element, or field is displayed and edited. FUNCTION codes can be included in a PICTURE clause. In this case, the PICTURE clause must start with @. Also, a PICTURE clause can contain FUNCTION codes, PICTURE codes, or both. Since a FUNCTION clause affects the entire expression, it can contain only FUNCTION codes.

        FUNCTION
         Code    Purpose
          A      Allows alphabetic characters only (no spaces or
                  punctuation marks).
          B      Left-justifies numeric data within the text box.
          D      Uses the current SET DATE format.
          E      Edits Date-type data as a BRITISH date.
          I      Centers text within the text box.
          J      Right-justifies text within the text box.
          K      Selects the entire text box when the cursor is
                  moved to the text box.
          L      Displays leading zeros (instead of spaces) in the
                  text box. Use with numeric data only.
          MList  Creates multiple preset choices. List is a
                  comma-delimited collection of items. Individual
                  items within the list cannot contain embedded
                  commas. If MemVarName or FieldName initially do
                  not contain one of the items in the list when
                  READ is issued, the first item in the list is
                  displayed. To scroll through the list, press the
                  Spacebar or type the first letter of an item. To
                  choose one of the items and move to the next
                  control, press Enter. Use with character data only.
          R      Displays a format mask in a text box. These mask
                  characters are not stored to the field when you
                  exit the text box. Use with character or numeric
                  data only.
          Sn     Limits the text box to n characters. You can scroll
                  within the region with the cursor control keys.
                  Use with character data only.
          T      Trims leading and trailing blanks from MemVarName
                  or FieldName.
          Z      Displays MemVarName or FieldName as blank if its
                  numeric value is 0. Use with Numeric data only.
          !      Converts alphabetic characters to uppercase. Use
                  with Character data only.
          ^      Displays numeric data using scientific notation.
                  Use with Numeric data only.
          $      Displays the currency symbol before numeric data.
                  Use with numeric data only.
          A PICTURE expression can include any characters, but only
                  the characters listed below determine how the text
                  box is displayed and edited.
      
      Source: Visual FoxPro Version 3 Help File
      
        PICTURE
         Code   Purpose
          A     Allows the entry of alphabetic characters only.
          L     Allows  the entry of logical data only.
          N     Allows the entry of letters and digits only.
          X     Allows the entry of any character.
          Y     Allows you to enter Y, y, N, and n for the logical
                 values true (.T.) and false (.F.), respectively.
          9     Allows entry of only digits in character data.
                 Allows entry of digits and signs in numeric data.
          #     Allows entry of digits, blanks and signs.
          !     Converts lowercase letters to uppercase letters.
          $     Displays the current currency symbol specified by
                 SET CURRENCY. By default, the symbol is placed
                 immediately before or after the numeric value.
                 However, the currency symbol and its placement
                 (SET CURRENCY), the separator character
                 (SET SEPARATOR), and the decimal character
                 (SET POINT) can all be changed.
          *     Asterisks are displayed in front of a numeric value.
                 Use with a dollar sign ($) for check protection.
          .     A decimal point specifies the decimal point position.
          ,     A comma is used to separate digits to the left of
                 the decimal point.
      
      Source: Visual FoxPro Version 3 Help File
      

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/14/1998
      Edided: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 15 [Prev][Top][Bottom]
      Visual FoxPro Interactive Mode: I hit Alt+F4 or clicked on the Close Box and Lost a lot of Work. How do I stop this?...

      Basically, you need to create a program that warns you that the SHUTDOWN event has happened. The following will do just that...

      Create a program with the following (or similar) code, or copy/paste what I have here. I called my program VFPSYSQUIT.PRG and saved it in my Visual FoxPro directory.

      * VFPSYSQUIT.PRG  06/15/1998 06/15/1998
      
      local OK2QuitVFP  && Is it OK to quit the Visual FoxPro Application?
                        && Interactive Mode, Prevent Accidental Quiting
      
      OK2QuitVFP = messagebox( "Are you sure you really want to quit Visual FoxPro?";
                   +chr(13)+chr(13)+;
                   "(Before saying Yes, make sure you have saved your work)",;
                   4+16+256, "Quit Visual FoxPro?")
      
      *   4 for Yes/No Button ; see MessageBox in FoxPro Help File
      *  16 for Stop Sign
      * 256 default button is the second one
      
      if( OK2QuitVFP = 6) then && see MessageBox in FoxPro Help File, 6 is for Yes
        quit
      endif
      
      * end-of-VFPSYSQUIT.PRG
      

      Installing your "Are you sure?" program....

      In the Command Window type ...

        ON SHUTDOWN DO \VFP\VFPSYSQUIT.PRG
      

      Include the approprate drive, path and filename for your situation.

      or add the following line to your CONFIG.FPW file, normally in your Visual FoxPro directory...

        COMMAND = ON SHUTDOWN DO \VFP\VFPSYSQUIT.PRG
      

      Be sure to include the approprate drive, path and filename for your situation.

      Adding this to your CONFIG.FPW will elimate you forgetting to enter the command through the Command Window. Test the program, before you start using it realtime, to make sure that it is working correctly and that it is being loaded.

      I have included some the nDialogBoxType codes used by MESSAGEBOX() and some other basic information about MESSAGBOX(). Refer to the Visual FoxPro Help file for more information about MESSAGEBOX().

      MESSAGEBOX() Function

      Displays a user-defined dialog box.

      Syntax

        MESSAGEBOX(cMessageText [, nDialogBoxType [, cTitleBarText]])
      

      Omitting nDialogBoxType is identical to specifying a value of 0 for nDialogBoxType.

        Value   Dialog box buttons
          0     OK button only.
          1     OK and Cancel buttons.
          2     Abort, Retry, and Ignore buttons.
          3     Yes, No, and Cancel buttons.
          4     Yes and No buttons.
          5     Retry and Cancel buttons.
      
        Value   Icon
         16     Stop sign.
         32     Question mark.
         48     Exclamation point.
         64     Information (i) icon.
      
        Value   Default button
          0     First button.
        256     Second button.
        512     Third button.
      

      nDialogBoxType can be the sum of up to three values; one value from each of the preceding tables. For example, if nDialogBoxType is 290 (2+32+256), the specified dialog box has the following characteristics:

        *  Abort, Retry, and Ignore buttons.
        *  The message box displays the question mark icon.
        *  The second button, Retry, is the default.
      

      Remarks

      The value MESSAGEBOX() returns indicates which button in the dialog box was chosen. In dialog boxes with a Cancel button, pressing ESC to exit the dialog box returns the same value (2) as choosing Cancel.

      The following table lists the values MESSAGEBOX() returns for each button.

      Return
      value   Button
        1     OK
        2     Cancel
        3     Abort
        4     Retry
        5     Ignore
        6     Yes
        7     No
      

      Source Visual FoxPro Version 5 Help File

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/15/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 16 [Prev][Top][Bottom]
      Create a Julian Date (YJJJ and KYJJJ) from a Date (MM/DD/YYYY) (Year 2000 Compatible)...

      The format that I use for Julian date is YJJJ, were Y is the last digit of the year, ie, 1998 would be 8. The JJJ is the number of the day in the year. January 1st is 1, February 15th is 46, etc. This format is not appropriate for the change of the century, Y2K, or for changing decades, 1980 to 1990. I've added a character to the front of the string, so the format it KYJJJ. K is a letter, "A", "B", "C", etc. "A" is for 199, "B" is for 200, "C" is for 201, etc.

      Create a Julian date using a date string

      yrDate = str(year(ctod(strDate))) && Year of the Date, 4 digit year
      yrcDate = right(yrDate, 1) && last digit of the year 1998 --> 8
      
      * Format: YJJJ, Add 1; 1/1/98 - 1/1/98 should equal 1
      
      JDate = yrcDate + PADL(ctod(strDate) - ctod("01/01/"+yrDate) + 1, 3, "0")
      
      * Y2K, Possible Solution. Increase the Julian date a variable to
      * 5 character field
      *
      * A> 1990 - 1999, B> 2000 - 2009, C> 2010 - 2019, etc
      *
      * Does not support dates earlier that 1990, if earlier dates are needed
      * -- have "A" represent the earlies date, ie, let say you need dates of
      * 1970 and later - "A" would be for 197, "B" for 198, "C" for 199, etc.
      *
      * 1998> 199; 1999> 199; 2000> 200; 2001> 200; ... 2010> 201
      
      yrFirst3 = val(left(yrDate, 3))
      
      *  A; 199, B; 200, C; 201, D; 202
      
      cY2K = chr(asc("A") + (yrFirst3 - 199))
      
      JDate = cY2K + JDate && Format: KYJJJ ;K - Y2K Character
      

      Create a Julian date using a date variable

      yrDate = str(year(dteDate)) && Year of the Date, 4 digit year
      
      yrcDate = right(yrDate, 1) && last digit of the year 1998 --> 8
      
      * Format: YJJJ, Add 1; 1/1/98 - 1/1/98 should equal 1
      
      JDate = yrcDate + PADL(dteDate - ctod("01/01/"+yrDate) + 1, 3, "0")
      
      * Y2K, Possible Solution. Increase the Julian date a variable to
      * 5 character field
      *
      * A> 1990 - 1999, B> 2000 - 2009, C> 2010 - 2019, etc
      *
      * Does not support dates earlier that 1990, if earlier dates are needed
      * -- have "A" represent the earlies date, ie, let say you need dates of
      * 1970 and later - "A" would be for 197, "B" for 198, "C" for 199, etc.
      *
      * 1998> 199; 1999> 199; 2000> 200; 2001> 200; ... 2010> 201
      
      yrFirst3 = val(left(yrDate, 3))
      
      *  A; 199, B; 200, C; 201, D; 202
      
      cY2K = chr(asc("A") + (yrFirst3 - 199))
      
      JDate = cY2K + JDate && Format: KYJJJ ;K - Y2K Character
      

      Y2K Information
      Year 2000 Information

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/16/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 17 [Prev][Top][Bottom]
      Create a Date (MM/DD/YYYY) from a Julian Date (YJJJ and KYJJJ) (Year 2000 Compatible)...

      The format that I use for Julian date is YJJJ, were Y is the last digit of the year, ie, 1998 would be 8. The JJJ is the number of the day in the year. January 1st is 1, February 15th is 46, etc. This format is not appropriate for the change of the century, Y2K, or for changing decades, 1980 to 1990. I've added a character to the front of the string, so the format it KYJJJ. K is a letter, "A", "B", "C", etc. "A" is for 199, "B" is for 200, "C" is for 201, etc.

      YJJJ Julian Date Format: Create a Date (MM/DD/YYYY) using a Julian date string

      yrcDate = left(jdate,1) && last digit of the year 1998 --> 8
      yrDate = "199"+yrcDate && Year for the Date, ASSUME 199
      
      * Create the date for January 1st of the Year, add the
      * Julian Date number and then subtract 1 to make it right.
      * January 1st is Julian number 1, not 0
      
      dteDate = ctod("01/01/"+yrDate) + val(right(jdate,3)) - 1 && Date format
      
      strDate = dtoc(dteDate) && Date in a string variable
      

      KYJJJ Julian Date Format: Create a Date (MM/DD/YYYY) using a Julian date string

      kcDate = left(kjdate,1)  && Get the "A", "B", "C", etc
      yrcDate = right(left(jdate,2),1) && Get the Year digit
      
      * Create the year based on the "A", "B", "C", etc plus the Year Digit
      * Calculate the ASCII Value difference between "A" (meaning 199) and the
      * kcDate character. Add the difference to 199. For example, "B" - "A" = 1,
      * add 1 to 199 to get 200. "B" stands for "200"
      
      yrDate = str(199+(asc(kcDate)-Asc("A")))+yrcDate
      
      * Create the date for January 1st of the Year, add the
      * Julian Date number and then subtract 1 to make it right.
      * January 1st is Julian number 1, not 0
      
      dteDate = ctod("01/01/"+yrDate) + val(right(jdate,3)) - 1 && Date format
      strDate = dtoc(dteDate) && Date in a string variable
      

      Y2K Information
      Year 2000 Information

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/16/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 18 [Prev][Top][Bottom]
      Future


      [Index][Next] 19 [Prev][Top][Bottom]
      Grid: How do I Add (Delete) a column(s) to an existing Grid Control?...

      DON'T USE the Grid Builder. If you do, you will be sorry... Trust me I KNOW from experience!

      Adding a column(s) to an exiting Grid Control

      Adding a column(s) to the control is not hard, it's the configuring that takes the time.

      Here are the steps required to add a column(s) to your existing Grid Control. Click on the Grid Control, to make it the active control. In the Properties dialog you should see the name of your Grid in the drop down list box. If you do, find the ColumnCount Attribute and change it to the total number of columns you want in your control. If you're adding, then the new number should be larger than what is there<grin>. Click on the check mark and save as normal.

      That's it, if the new number is larger than it was -- you will have X number of new columns added to the end of your grid. If the number is smaller, then you lost X number of columns from the end.

      At this point you will have to configure the new column(s) -- set the Heading, ControlSource, InputMask, StatusBarText, etc.

      If you need to change the order of the Columns then you will be updating the ColumnOrder Attribute under the Column (ColumnXX) data.

      Deleting a column(s) in an exiting Grid Control

      Warning! Warning! Warning! the columns that are removed are the ones at the right end of the grid. If you don't want these columns removed, then you need to rearrange your Grid so that the ones that are on the right end are the ones that you want removed.

      To delete a column(s) from your existing Grid Control, you need to Click on the Grid Control, to make it the active control. In the Properties dialog you should see the name of your Grid in the drop down list box. If you do, find the ColumnCount Attribute and change it to the total number of columns you want. Click on the check mark and save as normal.

      The columns that are removed are the ones from the right end.

      Remember and NEVER FORGET!, the changes DO NOT take effect until you save. If you're not happy with the change(s), close the Form with the Grid and say NO to the save question.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/17/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 20 [Prev][Top][Bottom]
      List of Code Characters for the FORMAT Attribute...

      FORMAT Property

      Specifies the input and output formatting of a control's Value property. Available at design time and run time.

      The Format Attribute sets the properties for the field as a whole. Whereas, the InputMask is a character by character format for the field.

      Refer to your Visual FoxPro Help File for more information about Format and InputMask.

      The valid cFunction settings for an EditBox control are:

        Setting Description
          K     Selects all the text when the control gets the focus.
          The   valid cFunction settings for a Spinner control are:
      
        Setting Description
          $     Displays the currency symbol.
          ^     Displays numeric data using scientific notation.
          K     Selects all the text when the control gets the focus.
          L     Displays leading zeros (instead of spaces) in the text box.
          R     Displays the format mask for the text box that is specified in the
                InputMask property. The mask formats data for easier entry and
                clearer display (for example, if the mask is 99-999, the number
                12345 is displayed as 12-345), but is not stored as part of the
                data. Use only with character or numeric data.
      
          Z     Displays the value as blank if it is 0 except when the control has
                the focus.
      
      

      The valid cFunction settings for a TextBox control and Column object are:

        Setting Description
          !     Converts alphabetic characters to uppercase. Use with Character
                data only.
      
          $     Displays the currency symbol. The ControlSource property must
                specify a numeric source for the textbox.
      
          ^     Displays numeric data using scientific notation. The ControlSource
                property must specify a numeric source for the textbox.
      
          A     Allows alphabetic characters only (no spaces or punctuation marks).
          D     Uses the current SET DATE format.
          E     Edits Date values as British dates.
          K     Selects all the text when the control gets the focus.
          L     Displays leading zeros (instead of spaces) in the text box. The
                ControlSource property must specify a numeric source for the
                textbox.
      
          M     Included for backward compatibility.
          R     Displays the format mask for the text box that is specified in the
                InputMask property. The mask formats data for easier entry and
                clearer display (for example, if the mask is 99-999, the number
                12345 is displayed as 12-345), but is not stored as part of the
                data. Use only with character or numeric data.
      
          T     Trims leading and trailing blanks from the input field.
          YS    Displays Date values in a short date format determined by the
                Windows Control Panel short date setting.
      
          YL    Displays Date values in a long date format determined by the
                Windows Control Panel long date setting.
      

      The Format property specifies a behavior for the entire input field. You can mix several Format codes, but they always affect everything in the input field. This property contrasts to the InputMask property in which each entry in the input mask corresponds to an entry in the input field.

      Source Visual FoxPro Version 5, Help File

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/17/1998
      Edited: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 21 [Prev][Top][Bottom]
      How do I Cascade the MDI Child Windows in my application?...

      Visual FoxPro only provides an "Arrange All" option. This option Tiles the MDI Child Windows. I prefer the Cascade, it is more useful for my current need and I want to provide a Cascading option for my users. It is an option that users expect and is consistant with other Windows Applications.

      I ran across some Visual FoxPro code by Mike Lewis, [eMail] [Homepage], to do this. (Drop by Mike's webpage and see his FoxStuff for his Tips and Tricks. His cascade routine is there. If you need some consulting work, he might be the consultant for you.) He got me started, but like most programmers -- I couldn't leave it alone <G>. I have made several changes and enhancements to his original code.

      When I first started looking for a way to Cascade the Child Windows, Brad Schulz, [eMail], of the Visual FoxPro Forum (GO VFOX) gave me some very basic code. Based on what Mike and Brad told me, here is what I came up with...

      Advertizement: If you are not a member of Compuserve I highly recommend that you join. The Visual Fox Forum (GO VFOX) is an outstanding resource. For example, I posted a question in the VFOX Forum, right after lunch, and within 2 to 3 hours, that day -- I had the enhancement added to my program. I had gotten a reply, with the information that I needed, and with that information was able to implement the enhancement. I don't know of another resource that can provide that kind of timely help. If you are a memeber and you don't drop by -- then you should start. There are other wonderful forums - covering - Visual Basic, PowerBuilder, Visual C++, etc.

      I have included the following code in my Windows | Cascade (\<Cascade) Procedure...

        * Cascade MDI Child Windows by Richard Hendricks 06/19/1998 .. 08/11/1998
      
        local lnNewWidth, lnNewHeight, lnNewLeft, lnNewTop, lnFmIdx
        local lnTopOffset, lnLeftOffset, slnNewLeft, slnNewTop
        local lnNumToCascade, lnLeftCouldFit, lnTopCouldFit, lnWinCouldFit, llForceULeft
      
        llForceULeft = .f.
      
        lnTopOffset = Sysmetric(9) * 1.2  && horizontal offset, height of
                                          && Window Title bar; add some to space it out some
        lnLeftOffset = Sysmetric(9) * 1.2 && vertical offset
      
        lnNewWidth = 0.80 * _SCREEN.Width && new window width
        lnNewHeight = 0.70 * _SCREEN.Height && new window height
      
        * Handle very small main MDI Windows
        IF(lnNewWidth < 3 * lnLeftOffset) THEN
          lnNewWidth = 3 * lnLeftOffset
        ENDIF
        IF(lnNewHeight < 3 * lnTopOffset) THEN
          lnNewHeight = 3 * lnTopOffset
        ENDIF
      
        * Determine how many windows there are to cascade
        lnNumToCascade = 0
      
        FOR lnFmIdx = 1 TO _SCREEN.FormCount
          WITH _SCREEN.Forms(lnFmIdx)
           * Don't count mimimized windows
           IF (Type(".WindowState")<>"U" AND .WindowState = 1) THEN
             LOOP
           ENDIF
          lnNumToCascade = lnNumToCascade + 1
          ENDWITH
        ENDFOR
      
        lnNewLeft = _SCREEN.Width - lnNewWidth - 10
        lnNewTop =  _SCREEN.Height - lnNewHeight - 10 - SysMetric(9) && account for status line
      
        lnLeftCouldFit = Int(lnNewLeft / lnLeftOffset)
        lnTopCouldFit = Int(lnNewTop / lnTopOffset)
        lnWinCouldFit = Min(lnLeftCouldFit, lnTopCouldFit)
        IF(lnWinCouldFit <= 0) THEN
          lnWinCouldFit = 1 && force left/top to be 0, 0 for all windows
                            && very small Main MDI Frame
          llForceULeft = .t.
        ENDIF
      
        * Fewer than, equal to the number of Windows to Cascade, (or Force Upper Left)
        * than there is room for
        * Note: if only 1 Window to Cascade, position it at 0, 0
        IF (lnNumToCascade <= lnWinCouldFit or llForceULeft = .t.) THEN
          lnNewLeft = (lnLeftOffset * (lnNumToCascade-1))
          lnNewTop = (lnTopOffset * (lnNumToCascade-1))
        ELSE
          * More Windows to Cascade, than there is room for -- layers of
          * Cascaded Windows
          lnNewLeft = (lnLeftOffset * (lnWinCouldFit))
          lnNewTop = (lnTopOffset * (lnWinCouldFit))
        ENDIF
      
        slnNewLeft = lnNewLeft && save starting position
        slnNewTop = lnNewTop && save starting position
      
        FOR lnFmIdx = 1 TO _SCREEN.FormCount
          WITH _SCREEN.Forms(lnFmIdx)
             * Don't resize/cascade mimimzied windwos
             IF (Type(".WindowState")<>"U" AND .WindowState = 1) THEN
               LOOP
             ENDIF
             * If resizable then Resize it
             IF (Type(".BorderStyle")<>"U" AND .BorderStyle = 3) THEN
              * Set window height and width, windows resize event will
              * take care of min/max values
              .Width = lnNewWidth
              .Height = lnNewHeight
             ENDIF
      
             * Move the Window to its new position
             IF ((lnNewTop >= 0) and (lnNewLeft >=0)) then
               * The window will fit on the main window, ok
               .Move(lnNewLeft,lnNewTop)
               * Calculate the position of the next window
               lnNewLeft = lnNewLeft - lnLeftOffset
               lnNewTop = lnNewTop - lnTopOffset
             ELSE
               * Window would be off the main window, so go back
               * to original top and left corner
               .Move(slnNewLeft, slnNewTop)
               lnNewLeft = slnNewLeft - lnLeftOffset
               lnNewTop = slnNewTop - lnTopOffset
             ENDIF
          ENDWITH
        ENDFOR
      
        * end-of-Cascade
      

      Comments...

      • The routine handles the situation where the main MDI Frame is very small.
      • The placement of the MDI Child Windows is much better than it was in the first version.
      • The routine does not change the location of mimimized windows.
      • The method for setting the size of the windows is quite simple. If the specific window has size limites,
        then I depend on the windows resize event to take care of itself.
      • If a window is not resizeable; I position it in the cascade, but do not change it's size.
      • There is no problem, if there aren't any MDI Child Windows to Cascade.

      Related Tips...

        How do I add an Open Windows List to the end of my Windows Menu?...
        How do I Arrange the Minimized MDI Child Windows in my application?...
        How to Auto-Cascade MDI Child Windows...

      I hope that you find this useful. If you find any problems or have any suggestions, please let me know.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/20/1998 .. 08/11/1998
      Helper: Mike Lewis [eMail] [Homepage]
      Helper: Brad Schulz [eMail]
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 22 [Prev][Top][Bottom]
      How do I Enable/Disable Menu options?...

      Sometimes, you do not want your user to be able to select a menu option while they are in the process of using that option. For example, they are in the configure application dialog. You wouldn't want them to have two instances of that dialog open at the same time.

      Other times you might not want them to select a Menu option because all the requirements for the option are not present. For example, a certain file is not available, there is nothing to print, there isn't anything selected -- so they can't copy to clipboard, etc. These situations can be handled by using the "Skip for" attribute for the selection or by the following.

      Menu's are made up of pads or options that the user can select. You can enable/disable the selection on the Menu bar (effectively disabling all the sub selections) or individual entries on a menu.

      To enable/disable an entry on a menu, lets say the "Configure" option on the "Options" menu, you would do the following...

      You need to set or determine the Bar Number for the "Configure" selection. Let's say it is 56.

      To set it, in the Menu Builder, you would find the "Configure" entry on the "Options" Menu (similar to File, Window, etc). Click on the "Configure" line and under the "Options" column - click on the little gray button. This will bring up a dialog box that has several entries on it.. "Key Label", "Skip for", "Bar #", "Message", etc. In "Bar #" field, enter the number you want the bar to have. In this case enter 56. Press the OK button and save the menu.

      I assign these based on the location of the selection within the whole menu system. In this example, the "Options" Menu is the 5th selection on the menu bar and "Configure" is the 6th selection under it. The Bar numbers can be duplicated across menus, File, Edit, ..., Window, Help, because you use the number and the name to designate what selection to enable/disable.

      Disable the "Configure" selection...

      In the INIT Event of the form that is opened when you click on "Configure" Selection, put...

        SET SKIP OF 56 OF OPTIONS .T.
      

      Enable the "Configure" selection...

      In the Destroy Event of the form that is opened when you click on "Configure" Selection, put...

        SET SKIP OF 56 OF OPTIONS .F.
      

      When the user selects the "Configure" option, the form will disable the menu selection. When the user closes the form, the menu selection will be enabled.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/20/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 23 [Prev][Top][Bottom]
      How do I Print the contents of an Edit Box from the File | Print?...

      I needed to be able to print the contents of an Edit Box from the File | Print menu selection. There could be multiple instances of the Form and Edit Box with different text. So, I needed to make sure that I printed the correct text. This technique can be used to print text in labels, Text Boxes, database fields, variables, etc.

      I have a PUBLIC variable prTextToPrint that is declared in the startup program. I set the value of prTextToPrint to "". If prTextToPrint is empty, then the File | Print selection is disabled.

      Whatever text is stored in prTextToPrint will be printed, so you can put whatever text you need printed in prTextToPrint. For example, you could load the contents of a Grid or the text from all the Text Boxes and Edit Boxes on the form.

      In the "Skip for" of the "Print" selection, put "empty(prTextToPrint)" (without the quotes).

      To set this, using the Menu Builder, you would find (or create) the "Print" entry on the "File" Menu. You need to have your own "Print", not the one FoxPro give you with Quick Menu -- because you want to have control of it. Click on the "Print" line and under the "Options" column - click on the little gray button. This will bring up a dialog box that has several entries on it.. "Key Label", "Skip for", "Bar #", "Message", etc. In "Skip for", enter "empty(prTextToPrint)" (without the quotes). Press the OK button. Save the menu.

      In the "Activate" Event of any form that will be using the File | Print selection. Set the value of prTextToPrint to the text that you want printed. In the case of my Edit Box, I had something like THISFORM.edtViewDetails.Text. When the user selects the form, then the appropriate text will be loaded into prTextToPrint. This will enable the File | Print selection.

      In the "Deactivate" and "Destroy" Event of these forms, set the value of prTextToPrint to "". When the user leaves the form or closes it -- prTextToPrint will be cleared, thus disabling the File | Print selection.

      The following routine is in the File | Print Procedure. The user is ask what printer (GETPRINTER()) to print to. If the user selects one, then the text (if there is any), in prTextToPrint, will be printed -- otherwise nothing is printed. The status of the printer is checked (PRINTSTATUS()). The user is notified when the printing is done and if there is a problem.

      You might want to remove the message about the printing being done or replace it with a "WAIT ... WINDOW TIMEOUT nSec.".

        prSelected = GETPRINTER()
        IF(LEN(TRIM(prSelected)) > 0 and !EMPTY(prTextToPrint)) THEN
          SET PRINTER TO NAME (prSelected)
          if(PrintStatus() = .t.) then
            SET PRINTER ON
            ?? prTextToPrint
            EJECT
            SET PRINTER OFF
            SET PRINTER TO
            =messagebox("Report Printed...", 0, "Print")
          else
           =messagebox("There is a problem with the printer", 0+16,;
            "Printer problem...")  && Stop Sign
          endif
        ENDIF
      

      This routine uses the standard FoxPro font. You can add to the routine the specifying of the Font, Size and Style with SET FONT. Refer to the Visual FoxPro Help File.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/20/1998
      Helper: Brad Schulz [eMail]
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 24 [Prev][Top][Bottom]
      Future


      [Index][Next] 25 [Prev][Top][Bottom]
      How do I store a BITMAP Copy of my Applicaiton (or Full Screen) in the Windows Clipboard?...

      The following technique uses a Windows API call to perform the equivalent of Alt-PrintScreen (copy window to clipboard) and PrintScreen (copy screen to clipboard). I found this information from a Tip by Matt Hart, [eMail] [Homepage], PRNTFORM.ZIP. His tip is for Visual Basic and with some minor changes I was able to convert it to Visual FoxPro code.

      Matt's copyright notice and disclaimer.

                    Copyright 1997 by Matt Hart
                        All Rights Reserved.
      
      This software is FREEWARE. You may use it as you see fit for
      your own projects but you may not re-sell the original or the
      source code. If you redistribute it you must include this
      disclaimer and all original copyright notices.
      
      No warranty express or implied, is given as to the use of this
      program. Use at your own risk.
      

      Save BITMAP Copy of Application to Clipboard..

      In Visual FoxPro or other MDI Applications, you can not just capture the current MDI Child Window to the Windows Clipboard. In the case of an MDI Application, the whole application will be captured to the Windows Clipboard.

        DECLARE keybd_event IN Win32api integer bVk, integer bScan,;
                long dwFlags, long dwExtraInfo
      
        = keybd_event( 44, 0, 0, 0 )
      

      Save BITMAP Copy of Whole Screen to Clipboard..

        DECLARE keybd_event IN Win32api integer bVk, integer bScan,;
                long dwFlags, long dwExtraInfo
      
        = keybd_event( 44, 1, 0, 0 )
      

      Note: Windows API function names are case sensitive.

      Note: Visual FoxPro Version 3, you may need to replace the "long" with "integer".

      Additional Reference:

        Microsoft Knowledge Base has an article entitled "How To Perform a Screen Capture Programmatically", Article ID: Q153003.

      Platform: Windows/95 and Windows/NT
      FoxPro: VFP/3 and VFP/5 Recorded: 06/22/1998 .. 06/24/1998
      Helper: Matt Hart [eMail] [Homepage]
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 26 [Prev][Top][Bottom]
      Quick/Short Tips and Tricks... (Little explaination and NO Frills!)

      Writing to the MDI Frames Status line

        SET MESSAGE TO [text]

        * OR *

        Set the StatusBarText Attribute

        06/20/1998

      Getting Visual FoxPro to generate a Quick Menu

        File | New

        Select Menu radio button

        Click on New file button

        Click on Menu button

        Menu | Quick Menu

        Note: Quick Menu is only available on a new/empty menu
        Note: Quick Menu is a copy of the Visual FoxPro Menu system. Useful for a good starting point.
        06/20/1998

      Adding Menu Option: "Close All" MDI Child Windows

        Open up your menu in the Menu Builder

        Find the location in your menu system, where you want Close All. Typically, this is on the Windows Menu.

        Position the cursor on the entry above which you want Close All

        Click on Insert Bar...

        From the Insert System Menu Bar dialog, select Close All

        Click on the Insert button

        06/20/1998

      Quick Help for a Topic

        In the FoxPro Command Window you can type in Help topic

        You can also get help by highlight the topic and press F1

        The topic you type in or highlight can be just a partial spelling of a topic title

        06/21/1998

      TRANSFORM() has some interesting options

        Convert Decimal Number to Hexidecimal Number

           ? TRANSFORM( 10, "@0") ; 0x0000000A
        

        Function to convert Hexidecimal to Decimal

          FUNCTION Hex2Dec
          *-- This function converts Hexidecimal (Char) to Decimal (Integer).
          *-- Input:  Character
          *-- Output: Numeric
        
          PARAMETERS InStr
          InStr=ALLTRIM(InStr)
          PRIVATE ALL LIKE J*
          jLen=LEN(InStr)
          nSum=0
          rPtr=0
          FOR nCtr= 1 TO jLen
            cPtr=UPPER(SUBSTR(InStr,jLen-rPtr,1))
            DO CASE
                CASE cPtr='A'
                     cPtr='10'
                CASE cPtr='B'
                     cPtr='11'
                CASE cPtr='C'
                     cPtr='12'
                CASE cPtr='D'
                     cPtr='13'
                CASE cPtr='E'
                     cPtr='14'
                CASE cPtr='F'
                     cPtr='15'
            ENDCASE
            nSum=nSum+(VAL(cPtr) * 16^(nCtr-1))
            rPtr=rPtr+1
          ENDFOR
          RETURN(nSum)
        

        Convert Logical .T./.F. to Y/N

           ? TRANSFORM( .T., "Y") ; Y
        
          Format
          Codes  Description
           @C    CR is appended to positive currency.
           @D    Date and DateTime values are converted to the current SET DATE format.
           @E    Date and DateTime values are converted to a BRITISH date format.
           @T    Leading and trailing spaces are trimmed from character values.
           @X    DB is appended to negative currency.
           @Z    If 0, currency or numeric values are converted to spaces.
           @(    Encloses negative currency or numeric values in parentheses.
           @^    Converts currency or numeric values to scientific notation.
           @0    Converts numeric or currency values to their hexadecimal equivalents.
           !     Converts character data to uppercase.
           $     Adds the current currency symbol.
           X     Specifies the width of character values.
           Y     Converts logical true (.T.) and false (.F.) values to Y and N.
           !     Converts lowercase characters to uppercase.
           .     Specifies the decimal point position in currency and numeric values.
           ,     Separates digits to the left of the decimal point.
        
          See Visual FoxPro Help File for more information.
        
        06/23/1998

      Report Designer: How do I Preview the Report that I'm working on?

        In VFP/5, I do not see a Preview selection on any of the menus. There is a Run on the Report Menu and a "!" on the toolbar. Run wants to direct the report to a printer or a file.

        Right click on the background of the Report. You will get a popup menu with "Preview" on it.

        ** OR **

        Select View | Preview from the Visual FoxPro Menu.

        ** OR **

        Click on the Preview Icon on the Toolbar. The Icon is a white piece of paper with a magnifying glass and it is to the right of the Print Icon.

        06/28/1998 .. 07/09/1998

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/20/1998 .. 07/09/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 27 [Prev][Top][Bottom]
      Tips and Tricks about using Microsoft's Technical Support Knowledge Base...

      The Microsoft Technical Support Knowledge Base Homepage is a good place to start for information about Visual FoxPro (and other Microsoft Products).

      The Basic search allows for you to select the Product, Visual FoxPro, and then enter your question. Then you click on the "Find" button.

      If you don't have a question and simply want to browse the articles, then you might try some of the following...

      Search on...

      • HOWTO: (I had trouble with "How to" (with a space) with or without the quotes)
      • FIX:
      • BUG:
      • PRB:
      • INF: for Information
      • Visual FoxPro
      • Sample: or Sample
      • File:
      • Frequently Asked Questions (When I tried this I got about 30 Articles with that title.)

      Try these links...

      • Visual FoxPro Reports within the last 120 days
      • HOWTO: Search for FoxPro Articles Using KB-wide Keywords
      • HOWTO: Search for FoxPro Articles Using KBKeywords - Products and Platforms (91)
      • HOWTO: Search for FoxPro Articles Using KBKeywords - Microsoft FoxPro KBKeyword Major and Minor Keywords (23)
      • How to Find Answers Online

      Notes:

      • It appears that the maximum number of article that can be returned is 200.
      • Many times the articles at the end don't relate specifically to the search and/or product specified.

      Some interesting articles that I found...

      • HOWTO: Disabling Menu Titles and Bars
      • HOWTO: Prepare for the Year 2000
      • HOWTO: Providing Edit Menu Functions in a Top-Level Form
      • HOWTO: Simple Internet API Sample -- HTML Into Memo Field
      • HOWTO: Using SET PRINTER TO NAME to Specify Report Destination
      • HOWTO: Using SET SKIP OF PAD with Custom Menu Pad
      • How To Use the DataToClip Method
      • Programmatically Copying Text to/from Windows Clipboard
      • Reserved Words in Visual FoxPro
      • Use of SET BELL to Play a Waveform (.WAV) File in FoxPro
      • Differences Between FoxPro and Visual FoxPro

      See my Tip entitled List of Selected Microsoft Knowledge Base Articles... for more articles

      This was written with Visual FoxPro for Windows/95 in mind, but it can be applied to Windows 3.1, DOS and Macintosh -- as well as other products like Visual Basic, Excel, Word, etc.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/24/1998 .. 07/10/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 28 [Prev][Top][Bottom]
      How do I add an Open Windows List to the end of my Windows Menu?...

      It is common for MDI (Multiple Document Interface) Windows Applications to have a list of open MDI Child Windows. The Visual FoxPro application has this list, but it is not obvious how to implement this feature.

      I found the required information in one of Microsoft's Knowledge Base Articles. The article is How to List the Currently Active Windows in a Menu.

      The article described what is reqired and how to write code to enable this feature. My tip describes how to do enable it through the Menu Builder.

      There are two things that are required. 1) The reserved name _MWINDOW must be used as the name of the menu popup. 2) There must be at least one menu bar (menu option) entry on the menu.

      The article also seems to imply that other things are required. For example, that there needs to be a pad called "----Active----" that is disabled and that when the Window menu is selected that it needs to execute RETURN "". These are not required.

      I am assuming that you already have a menu system defined and you have a sub menu, ie, Windows, that you want the Open Window List to be added to.

      If not, you need to create one. I have a tip about how to get FoxPro to generate a Quick Menu. You can also get what you need from the Visual FoxPro Help file.

      OK, let's get started...

      Open the Menu Builder and select the Menu Title, ie, \<Window, that you want the list added to. I'm assuming that you are going to add the list to the Window Menu.

      Click on the Edit button on the \<Window line.

      Click on the Menu Level Drop Down List box and insure that the entry relatd to the Window menu is selected.

      Go to the FoxPro System Menu and select View | Menu Options

      On the Menu Options dialog window, set the name to _MWINDOW. It is very important that you use this exact name. Case of the letters does not matter.

      Click on the OK button.

      If you have entries on your Window Menu, for example, Arrange All, Cycle, etc. Save the menu and build your applicaiton.

      You should see the list of MDI Child Windows at the end of your Window menu.

      If you do not have entries on your Window Menu, here are some you might add.

      Click on the Insert Bar... and select Arrange All. This is towards the end of the list. Click on OK. I changed the prompt to \<Tile. It's a little more Windows type terminology.

      Click on the Insert Bar... and select Close All. This is towards the beginning of the list.

      Click on the Insert Bar... and select Cycle. This is towards the end of the list. Click on OK.

      Save and Build your application. You should see the list of MDI Child Windows at the end of your Window menu.

      Related Tips...

        How do I add an Open Windows List to the end of my Windows Menu?...
        How do I Arrange the Minimized MDI Child Windows in my application?...
        How to Auto-Cascade MDI Child Windows...

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/24/1998 .. 08/11/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 29 [Prev][Top][Bottom]
      How do I Arrange the Minimized MDI Child Windows in my application?...

      Visual FoxPro only provides an "Arrange All" option. This option Tiles the MDI Child Windows and does nothing with the Minimized MDI Child Windows. I wrote a Cascade MDI Child Windows routine to give my users the ability to cascade the child windows. I also wanted to provide my users with the ability to arrange the icons, or minimized Child Windows of the MDI Application. Arrange Icons is an option that users expect and is consistant with other Windows Applications.

      I have included the following code in my Windows | Arrange Icons (Arrange \<Icons) Procedure...

        * Arrange Minimized MDI Child Windows by Richard Hendricks 06/28/1998 .. 06/28/1998
        LOCAL lnNewLeft, lnNewTop, lnFmIdx, lnMinWinHeight, lnMinWinWidth
      
        lnMinWinHeight = Sysmetric(17) * 0.8 && Trial and Error to determine this
        lnMinWinWidth = Sysmetric(16) * 5 && Trial and Error to determine this
      
        lnNewLeft = 0
        lnNewTop = _SCREEN.Height - lnMinWinHeight
      
        FOR lnFmIdx = 1 TO _SCREEN.FormCount
          WITH _SCREEN.Forms(lnFmIdx)
           * Don't arrange non-Minimized Windows
           IF (Type(".WindowState")<>"U" AND .WindowState <> 1) THEN
             LOOP
           ENDIF
           * Move the Minimized Window to its new position
           .Move(lnNewLeft,lnNewTop)
           * Calculate the position of the next Minimized Window
           lnNewLeft = lnNewLeft + lnMinWinWidth
            IF(lnNewLeft + lnMinWinWidth > _Screen.Width) THEN
              lnNewLeft = 0
              lnNewTop = lnNewTop - lnMinWinHeight
              IF(lnNewTop <= 0) THEN
                lnNewTop = _SCREEN.Height - lnMinWinHeight
              ENDIF
            ENDIF
          ENDWITH
        ENDFOR
      
        * end-of-Arrange Minimized Windows
      

      Comments...

      • The routine handles the situation where the main MDI Frame is very small.
      • The routine does not change the location of non-mimimized windows.
      • There is no problem, if there aren't any Minimized MDI Child Windows to Arrange.

      Related Tips...

        How do I Cascade the MDI Child Windows in my application?...
        How do I add an Open Windows List to the end of my Windows Menu?...
        How to Auto-Cascade MDI Child Windows...

      I hope that you find this useful. If you find any problems or have any suggestions, please let me know.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/28/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 30 [Prev][Top][Bottom]
      Report Designer: How do I change the text of a label (not the sticky ones<G>) control?...

      The reason I'm including this tip, is because I searched and struggled quite awhile for a way to change the text of label that Quick Menu assigned.

      Click on the [A] button, on the Report Controls Toolbar.

      Click on the text of the label, where you want to make the change. You can use the right and left arrow keys to move within the text.

      Change the text in the label.

      Click on the Upward Arrow button, on the Report Controls Toolbar, or click on the Report Designer someplace outside of the text. This will take you out of the edit mode.

      If you don't have a Report Controls Toolbar, then select View | Report Controls Toolbar from the Visual FoxPro main menu.

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 06/28/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 31 [Prev][Top][Bottom]
      How to Index Descending in an Ascending Index or visa versa...

      Before there was a DESCENDING order option on indexes, we would index the negative of our numbers to get a descending order sort. This works when you have an index of all numbers. Now! We don't have to do this, but this trick can be handy.

      If you have an index with strings in it and you have a number you want indexed descending. You can subtract the number from a big number and then convert the difference to a string. Lets say, your numbers range from 1 to 10. Subtract the number from 100. -- 1 becomes 99 and 10 becomes 90. Index on that and you get a descending order. Be sure that the length of the number does not change. Subtracting from lets say 11 would not be good. 1 would go to 10 and 10 would go to 1. The length of the STR() values are different and you want the length of each entry in the index to be the same length.

      Both of these tricks can be useful, in the right situation.

      Lets say you have a code, CODE1, that is numeric and you have a count or some other number (for this example lets use, count1) you want to include in the index. The second number, COUNT1, needs to be in descending order whereas the first number needs to be in ascending. If your index statement is INDEX ON CODE1 + (-1 * COUNT1), then CODE1 will be ascending and COUNT1 will be descending.

      Lets say that you want to look at the last 5 oil changes for your fleet of trucks. Index on the licence plate numbers (char) + str(9999999-milage). (I'm assuming that the maximum mileage is 999999.) The licence plate numbers will be in ascending order and the milages will be highest to lowest. Look at the first 5 records for the licence plate number.

      Platform: Windows/95
      FoxPro: dBase II, dBase III/+, FoxBase, ... ,VFP/3 and VFP/5 (All xBase)
      Recorded: 07/03/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 32 [Prev][Top][Bottom]
      How do I pass command line arguments to my application?...

      There are times that you might want to pass arguments to your application. You might want to pass in the users' name, what operation to perform or switches to influence the operation of your application. Visual FoxPro has a set of command line switches/options that can be used to influence how it operates. Hopefully, this tip will show you how to implement this feature in your own program.

      The way that you pass arguments to a PROCEDURE is to include a PARAMETERS statement as the first executable command (comments don't count, you can have those before the PARAMETERS statement) of the procedure. Basically, that is how you add this feature to your applicaiton.

      The first executable command in your application MUST be a PARAMETERS statement with the variable names specific for your application. You must include enough variables to support all of the command line arguments that the user will be using.

      Spaces and tabs are used to separate command line arguments. If the argument is quoted, then imbedded spaces and tabs will be included in the string the program receives. For example...

      You might want to ALLTRIM() the variable, to insure that no unwanted spaces are present.

      You will want to UPPER() or LOWER() the variables. This makes it easier for you to determine if the user has supplied a specific argument.

      The user can include these parameters in the ShortCut, Batchfile, command line, etc. So, you should expect some variation in what will be typed or passed to the program.

      Depending on your application, you might want to inform your user if any invalid option were entered.

      The PARAMETERS() function returns the number of parameters that were passed to the program, procedure, etc.

      Platform: Windows/95
      FoxPro: most earlier xBase versions, VFP/3 and VFP/5
      Recorded: 07/03/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 33 [Prev][Top][Bottom]
      List of Selected Microsoft Knowledge Base Articles...

      Microsoft Knowledge Base - Basic Search
      Microsoft Knowledge Base - Advanced Search
      Report
      • HOWTO: Modify Report Fields Programmatically
      • How To Add SQL SELECT to the Data Environment of a Report
      • How To Change the Default Source of Printer Programmatically
      • How To Create a Report Based on a Query
      • How to Access Report's Data Environment While the Report Runs
      • How to Modify a Report Preview Window Property
      • How to Print a Report When No Records Are Involved
      • PRB: Query Filter Has No Effect when Output to Report
      • PRB: REPORT FORM TO PRINT Results in Incorrect Data
      • Private Data Session Resets the Environment
      Menu
      • HOWTO: Disabling Menu Titles and Bars
      • HOWTO: Providing Edit Menu Functions in a Top-Level Form
      • HOWTO: Using SET SKIP OF PAD with Custom Menu Pad
      • How to List the Currently Active Windows in a Menu
      Grid
      • FIX: GridBuilder Gives Data Type Error After Fields Rearranged
      • How to Create Special Effects in a Grid
      • How to Manipulate DateTime Fields in a Grid
      • How to Set Up a Grid as a Destination for Drag and Drop
      • How to Set the Color and Font of Grid Rows Conditionally
      • PRB: Decimals Don't Display Properly in Grid
      Page Frame
      • HOWTO: Adding or Removing Pages from a PageFrame
      • How to Place Objects on Pages in a Pageframe
      • How to Simulate a Tabbed Dialog Box with Vertical Tabs
      • PRB: Controls in a Page Frame Are Not Refreshed
      Mouse Pointers/Cursors
      (Search on "MousePointer")
      • How To Change the Mouse Pointer to Any .CUR or .ANI File
      • How to Customize Icons & Mouse Pointers in Forms Designer
      • PRB: Animated Mouse Cursor Does Not Work in .exe File
      SQL - Structured Query Language
      • Calling a User-Defined Function (UDF) from SQL SELECT
      • Creating Modifiable Cursor in FoxPro with SQL SELECT
      • HOWTO: Create an SQL Command with > 255 Characters
      • HOWTO: Improving Performance of SQL Queries
      • How Memory & Disk Space Are Used During an SQL SELECT Command
      • How to Create a Dynamic SELECT Statement in an .EXE File
      • How to Determine Number of Records Returned by SQL-SELECT
        [_TALLY stores the count]
      • How to Display a SQL Cursor's Multiple Columns in a Combo Box
      • How to Force SELECT-SQL to Create Temp File for Cursor
      • Passing Variables to SELECT-SQL w/o Using Macro Substitution
      • Using Wildcard Characters in SQL Statements
      MS Graph
      (Search on "ms graph", "msgraph", "microsoft graph", "graph 5", "xy charts" or "ole automation")
      • Entering Microsoft Graph Without the RQBE Dialog Box
      • Example Code Shows How to Refresh a Graph
      • FILE: Gphsamp.exe Shows Automation to DataSheet in MS Graph 8
      • Graph 5.0: Cannot Use First Row for x Data on XY Scatter Chart
      • HOWTO: Change the Data Series in MSGraph Using the PlotBy Prop
      • HOWTO: Print Two Excel Charts on Single Page w/OLE Automation
      • How To Call the Graph Wizard & Create a Chart Programmatically
      • How To Create a 3-D Surface Graph in Visual FoxPro
      • How To Pass Data to Microsoft Graph Programatically
      • How To Perform Background Processing in FoxPro
      • How To Register an ActiveX Control (.ocx) Manually
      • How To Update a Graph in a Form
      • How To Use the Pinnacle Graph Control to Graph Data
      • How to Manipulate Embedded Objects in General Fields
      • How to Print Graphs Created in the Graph Wizard
      • INFO: Microsoft Graph Constants (TYPO: xl3DArea is defined as -409. It should be -4098)
      • INFO: Limitations of Run-Time MS Graph Note: There are SIGNIFICANT Limitations. BE CAREFUL!
      • MS Graph: Linked Data Overwrites Row and Column Headings
      • Microsoft Graph Does Not Create Custom Chart from Table
      • PRB: Error "OLE Error Code 0x80080005 Server Execution Failed"
        [Remove "at" symbol ("@") in the computer name]
      • PRB: Olegraph.scx Sample Fails if Graph 8 Is Installed
      • SAMPLE: Msgrp5cg.exe Graph Wizard Data Series Display Changes
      • XL: Adding Series to XY (Scatter) Chart with Second X Axis
      OLE (Object Linking and Embedding)
      • HOWTO: Debugging Remote Automation Servers in Visual FoxPro 5
      • HOWTO: Dynamically Create Excel 5.0 Charts in OLE 2.0 Control
      • How To Set Up OLE Automation in Visual FoxPro 5.0
      • How To Use the Object Property to Reference Methods/Properties
      • OLE Controls Available in Visual FoxPro
      • SAMPLE: Wd97vba.exe Contains Header File w/ Word VBA Constants
      FoxPro - Knowledge Base Lists
      • Popular Topics for Visual FoxPro
      • Visual FoxPro Bug List
      • Visual FoxPro Fix Lists
      • Visual FoxPro Articles for the Last 30 Days
      • Visual FoxPro Drivers and Other Downloads - Top Level Menu
      • Visual FoxPro related Drivers and Downloadable Files
      • Visual FoxPro Patches and Updates
      FoxPro - Miscellaneous Programming Tips and Tricks
      • HOWTO: Simple Internet API Sample -- HTML Into Memo Field
      • How To Perform a Screen Capture Programmatically
      • Programmatically Copying Text to/from Windows Clipboard
      • Use of SET BELL to Play a Waveform (.WAV) File in FoxPro
      • SAMPLE: Cdplayfx.exe Form Shows How to Play Audio CDs
      • How to Reboot the System from Within FoxPro
      • Using the Spelling Checker in FoxPro for Windows
      • How to Fill Second List with Values from Multiselect List Box
      FoxPro - General
      • Answers to Frequently Asked Questions
      • Base Classes Available in Visual FoxPro
      • Difference Between EVALUATE() and Macro Substitution
      • Differences Between FoxPro and Visual FoxPro
      • HOWTO: Prepare for the Year 2000
      • HOWTO: Using SET PRINTER TO NAME to Specify Report Destination
      • How To Use the DataToClip Method
      • How the EVALUATE() Function Works
      • How to Create a General-Purpose Thermometer Bar in FoxPro
      • How to Create a Wait-Processing Program/Window
      • How to Reference Objects in the Container Hierarchy
      • Macro Subst, Name Expr, and EVALUATE() Runtime Evaluation
      • Reserved Words in Visual FoxPro
      • Updated FOXTOOLS.WRI File for FoxPro for Windows
      • Visual FoxPro Language Tips and Tricks
      • Visual FoxPro Solution Sample Application
      Microsoft Knowledge Base usage
      • HOWTO: Search for FoxPro Articles Using KB-wide Keywords
      • HOWTO: Search for FoxPro Articles Using KBKeywords - Products and Platforms (91)
      • HOWTO: Search for FoxPro Articles Using KBKeywords - Microsoft FoxPro KBKeyword Major and Minor Keywords (23)
      • How to Obtain Microsoft Support Files from Online Services
      • Instructions for Using the Microsoft Download Service (MSDL)
      • KB List: Programming, Including OOP & Multiuser

      Microsoft Knowledge Base - Basic Search
      Microsoft Knowledge Base - Advanced Search

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 07/08/1998 .. 04/08/1999
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 34 [Prev][Top][Bottom]
      Microsoft's FTP (Download) Software Library...

      Microsoft has an FTP (Download) Site that contains a lot of patches, examples and free utilities.

      Take a look at the Index.txt file for the /Softlib/MSLFILES subdirectory. Use this file to find the files that you need. The files are stored in /Softlib/MSLFILES. There are lots of files here. Look around...

      The following link, takes you to the Microsoft's Software Library Files FTP Directory (/Softlib/MSLFILES). You will be presented with a FTP list of files. You can click on the file(s) that you want or add the filename to the URL ("ftp://ftp.microsoft.com/Softlib/MSLFILES/") in the "Location:" text box.

      Platform: Windows/95
      Products: All Microsoft Products including, Visual FoxPro Versions 3, 5 and 6
      Prepared: 07/31/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Index][Next] 35 [Prev][Top][Bottom]
      How to Auto-Cascade MDI Child Windows...

      When you have multiple instances of the same MDI Child form, they will be displayed on top of each other. This may also happen when you have lots of different Child MDI Forms.

      This tip provides a possible solution for this situation. This solution uses a Public Variable to help determine the placement of the next form/window to be displayed.

      I'm using the Sysmetric(9) function to determine the height of the window title bar. I use this number to set the top and left offset of the next form/window.

      I saw a similar tip in FoxPro Advisor, September 1998, page 74 by Keith Hekker. His tip requires that the form/window use a "private data session" and it for use with multiple instances of the same form. He uses the DataSessionID to determine the form/window placement.

      His tip didn't work for me because I wasn't using a "private data session".

        * Prior to the Showing of the Forms
      
        public piInstanceCount
        piInstanceCount = 0
      
        * Include in the Form's Init Event
      
        liOffset = Sysmetric(9) * 1.2 && height of Window Title bar
      
        THISFORM.Top = THISFORM.Top + (piInstanceCount * liOffset)
        THISFORM.Left = THISFORM.Left + (piInstanceCount * liOffset)
        piInstanceCount = piInstanceCount + 1
      

      This will cascade the windows down the Main MDI Frame. If you have a lot of windows, then you might want to MOD the value of piInstanceCount by 5 or 10. This should layer the windows in groups of 5 or 10. An alternative would be to check the value of piInstanceCount and set it back to zero when it gets too big.

        * Include in the Form's Init Event
      
        liOffset = Sysmetric(9) * 1.2 && height of Window Title bar
      
        THISFORM.Top = THISFORM.Top + ((piInstanceCount % 5) * liOffset)
        THISFORM.Left = THISFORM.Left + ((piInstanceCount % 5) * liOffset)
        piInstanceCount = piInstanceCount + 1
      

      Also see my tip on How do I Cascade the MDI Child Windows in my application?... and How do I Arrange the Minimized MDI Child Windows in my application?....

      Platform: Windows/95
      FoxPro: VFP/3 and VFP/5
      Recorded: 08/11/1998
      Author: Richard Hendricks [eMail] [Homepage]
      [Copyright & Disclaimer]


      [Top]

      Search:
      Keywords:
      In Association with Amazon.com

      Know what book or album you want?

      Enter the ISBN:
      (Leave out the dashes)




      Copyright and Disclaimer

      Copyright © 1998 by Richard Hendricks

      All Rights Reserved.

      Feel free to use these tips and tricks in your applications and feel free to share copies and the information to your friends and colleagues. You may not re-sell the original or the source code. If you redistribute it you must include the disclaimer and all original copyright notices.

      Do not remove the contributors names, copyright notices and disclaimer. Give credit where credit is due.

      The information given here is believed to be correct, but no legal liability can be accepted for its use.

      No warranty express or implied, is given as to the use of the information or source code. Use at your own risk.

      The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications.

      Microsoft Corporation holds the rights and copyrights for FoxPro, Visual FoxPro

      [Index][Top][Bottom]