DBFree coding conventions

Coding in MaxScript for DBFree you're strongly suggested to follow these rules:

Writing your code

  • Anywhere is possible use "camel" writing for namimg variables (like nDaysOfTheWeek or cMyAddress): avoid to use all uppercases or all lowercases.
  • Functions should start always with lowercase (getSessionId() is OK, GetSessionId() is deprecated
  • Commands in long, isolated statements without variables should go always uppercase
  • Commands appearing in statements or control structure togheter with functions or variables should stay lowercase, with some notably exception in long statements, where clarity sometime requires it
  • comment lines for code actions should start with //--
  • comment lines for embellishment of the code should start with *

Naming variables

  • variable names can be up to 35 characters, but only first 12 are significant
  • variable names can start only with letters and contain letters,numbers and underscores
  • String variables (supposed to contain text, a.k.a "character type") should always begin with a lowercase "c" like in cText
  • Numeric variables (supposed to contain numbers) should always begin with a lowercase "n" like in nDays
  • Date variables (supposed to contain "calendar dates") should always begin with a lowercase "d" like in dToday
  • Logical variables (supposed to be true or false) should always begin with a lowercase "l" like in lOk
  • As an alternative logical variables can start with lowercase "is" like in isOk or isExisting
  • Arrays should always start with a lowercase "a" like in aArray or aDaysOfWeek

Naming form fields

HTML forms contain "form fields"; they're used for most of user inputs and if you're planning to use MaxObjects it is compulsory that you follow these rules about naming them:

  • all form fields to be used as entryfield (supposed to be saved in a database) should start with an uppercase "EF_" like in EF_USERNAME; lowercase are allowed anytime form fields are supposed to be also manipulated by javascript. Remember this point because javascript do make a difference between upper and lowercase, while MaxScript does not.
  • all form fields to be used for MaxObjects (to pass values from page to page) but not to be saved into a database should start with an uppercase "VAR_" like in VAR_ACTION
  • all the private and local variables taking their values from a webvar should take the name of the webVar without the prefix VAR_ or EF_ and without underscores, and beginning with the lowercase letter most appropriate for the data type to assign them:
    • VAR_ACTION should be stored in cAction (a string)
    • EF_DATE_BIRTH (containing a string to transform to date) should be stored in dDateBirth
    • VAR_YES (containing a string to transform to logical) should be stored in lYes
    • EF_BALANCE (containing a string to transform to numeric) should be stored in nBalance

    WebVars (as all web form entryfields) are always passed as string, whatever was their original vale, and must be converted back to it when read from the destination page. Correctly naming them can greatly help to perform this task.