Reasons for code disappearing in a form method: a) pre-processor command mismatch b) saving the form c) virus scanners d) object memory corruption e) object code corruption
a) Code for an object is stored in a single memo field, one record for every object added to the form. When you save a method in the method code editor, VFP performs a validation on the structure of the code. If you ignore warnings or when code is manipulated outside the editor, you might end up with code where an #ENDIF line is missing. When VFP compiles the code this will remove all procedures until the next #ENDIF in any of the following procedures or the end of the memo file. b) The process of saving a form is as follows: Renaming the original file, saving the form under the old name, deleting the copy. Unfortunately, VFP does not verify if the form was saved correctly and might delete the backup file even when the form was saved incorrectly. This is, for instance, the case when there's a write lock on the SCT file while it is opened in an external program (mostly a viewer or a virus scanner). When VFP crashes while saving a form, you should search for a TMP file created around that time. It's the previous copy of the SCT file. c) The SCT extension is also used for scripts. As such, many virus scanners either block this extension or perform extra checks. If you experience issues with SCX files but not with VCX files, then excluding SCT files from the virus scan might fix the issue. d) Under some circumstances VFP keeps references to classes in memory. In most cases you either see a "Cannot modify class in use" error message or a prompt to clear the class from memory. Sometimes this doesn't happen though. In these cases one of two things might happen: 1) Any object based on this class is removed from the form. Saving the SCX file will not only permanently delete any code associated with the object but also the object itself. As SCXes are always recreated, you can't undelete older records as you sometimes can do with VCX files. 2) If the class in question is edited, you may be able to modify the class, but all methods are empty. e) The source code is in one memo field, the compiled code in another. The OBJCODE field contains the pointers which line belongs to which method. VFP uses these pointers whenever code is loaded into memory in the form designer. VFP creates these pointers only when compiling the code. When the OBJCODE field is empty, opening the form will not show any code. Saving the form will erase code, as the METHODS field is generated based on the code loaded previously. If the OBJCODE field is out of sync, methods will be splitted arbitrarily with ENDPROCs being in the middle of a code window or random binary characters appearing anywhere in the code. To fix OBJCODE issues you need to recompile the form with the COMPILE FORM command. Christof --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/cal4qjhirqicp7fvba1cnlaqxr0vyssngdjjbmm2ryfnchrz...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

