KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Automatically update method name in header
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: November 15, 2002

Compatibility: Version 6.7.x and 6.8.x

A useful programming habit is to include descriptive information at the top of each method. Many 4D programmers include comments like these:

` AddWeekdays
`
` $1 Date Initial date
` $2 Longint Weekdays to add
` $0 Date Resulting date
`
` Purpose: Calculate a new date based on weekdays rather than calendar days.

Unfortunately, if the method is renamed in 4D or 4D Insider, the original method name in the comments becomes incorrect. A simple solution for this problem is to include the method name itself within an impossible If structure, like this:

If (False)
AddWeekdays
`
` $1 Date Initial date
` $2 Longint Weekdays to add
` $0 Date Resulting date
`
` Purpose: Calculate a new date based on weekdays rather than calendar days.
`
End if

If the method name is changed with 4D Insider, the header is updated automatically. If the method name is changed with 4D, the header retokenizes to an unknown variable, a condition that can be detected automatically with SanityCheck or with 4D Compiler when using the "All variables are typed" option.