Advertising banner:

History
 
 A310
Home • Help • A0 • Customization Tools • FCAS • A310
 
General information on creating applications



Naming conventions
When you name FirstClass objects such as forms and fields, and code elements such as variables, constants, and subroutines, these names must:
•       begin with a letter
•       contain only letters, numbers, and the underscore character (_)
•       be no longer than 255 characters
•       differ from the names of BASIC operators and logical operators such as OR, AND, MOD, and NOT.
Examples:
•       Form
•       frm
•       FileOpen
•       frmFileOpen
•       Checkbox
•       chk
•       ReadOnly
•       chkReadOnly



Data types in code
Each variable in your code has a data type that determines what kind of data that variable can store. For example, string variables store text strings, and Integer variables store whole numbers.
Before you can use a variable in your code, you must declare it and its data type. This ensures that a variable only contains a value of the expected data type (for efficiency, FCAS does not support variables that can contain ambiguous data types).



End-of-line character constants
These end-of-line character constants can be used in any string:
& fcCr
& fcLF
& fcCRLF
For example, the internal function Str might have statements like this:
str1 = "Line One" & fcCR
str2 = "Line Two" & fcLF
str3 = "Line Three" & fcCRLF



Form modules
Form modules are one of the two fundamental types of modules in FCAS. They are an essential part of almost any application that you create in FCAS. They contain all the procedures that are assigned to forms and the fields on the forms.
FCAS lets you write event procedures which are run when users trigger any of an array of events for a field or the form itself. Each field type has a variety of event procedures that can execute BASIC code. For example, you can program the Click() procedure of a button to open a new window, or you can program the Change() method of a text field, which runs when the information contained in the field changes, to validate the new information.
Simple FCAS applications may use only a single form module. However, as a project grows, it may become necessary to add additional forms. If there are procedures that are used in more than one form, or are called from different fields on the same form, it may become necessary to put these procedures in a code module.



Code modules
Code modules are the other fundamental type of module in FCAS. They contain procedures that are global (that is, it is called from multiple forms, multiple fields on a form, or anywhere in the project), and can be accessed by any of the objects in the entire project. You can call the desired procedure from anywhere in your project with a single line of code.
This simplifies and streamlines projects by eliminating copies of identical code. When a procedure is modified, its changes are reflected everywhere the procedure is called, eliminating the need to remember to update all occurrences of duplicate code.
The code in code modules can take the form of:
•       subroutines
        Code that performs particular steps. Instead of repeating the code for a step wherever it is needed, you can call the subroutine.
•       variables
        A placeholder in your code for particular values, such as values that users have entered. You must declare a variable before you can use it.
•       constants
        Similar to variables, except the value of a constant can't be changed.
•       user-defined data types
        Combinations of related variables into single data structures.
•       declarations.
        A variable, constant, or user-defined type used when programming applications.



Field arrays
FCAS allows the creation of field arrays, which let you perform operations on groups of similar types of fields using an indexing method, rather than explicitly referencing a unique name for each field.
Field arrays are particularly useful when assigning properties to large groups of controls.
To create a field array, open the form you want to work with in FCAS and assign a name to a field. Then assign the same name to a field of the same type on this form. You will then be prompted to create a field array. The field will be assigned an index that will be visible in the Attributes window. Assigning the same name to additional fields of the same type on this form will include them in the field array.
After all the desired fields have been added to the field array, you can reference each field by its identifier in conjunction with its index.
As an example, this code will protect 100 checkboxes:
Dim i As integer
For i = 0 to 99
        cboMyCheckBoxArray(i).Protected = TRUE
Next



Box arrays
Box arrays are accessed in an identical fashion to arrays. Values can be retrieved or assigned using parentheses and an index. For example:
myBox(23) = "Hi there"
Before any manipulation of box arrays can occur, you must create a list by assigning values to each element of the box array in order, starting from the first element, 0. For example:
Dim i As Integer
For i = 0 to 99
MyBoxOfStrings(i) = "String #" & Stry(i)
Next i
After the list is created, it can't be collapsed. It can be reassigned. If the reassigned list is shorter than the original list, there will be dangling list items.
When a box array item gets focus, its index attribute is set. For example:
Sub Click()
        If MyBoxOfStrings.Index = 10, Then
        Print "You clicked the 10th item in the list"
        End If
End Sub
Box arrays include the Key attribute. In addition to the normal data value associated with an entry in a box array, each entry may now store a second, nondisplaying data value. The data value stored in the Key attribute may be of any type, but, once assigned at run time, this data type can't be changed. For example:
For i = 0 to 100
        BoxArray(i) = "Hi there"
        BoxArray(i).Key = "This is hidden Key #"; Str(i)
Next



Sharing variables across applications
Variables defined as SharedGlobal can be shared across all applications running on a given FCAS instance. They can be treated just as local or global variables within a program, but any program using them may change their value or even Redim or Redim Preserve them.
SharedGlobal variables can be of any type, including user-defined types. They can't be passed into Subs or Functions as they are global to the program and can be referenced at any point. SharedGlobal variables will not interfere with local or global variable naming unless they are defined in the program.
Keep in mind when using arrays that another program may redefine the dimensions of the array. Also be aware that a SharedGlobal may change value from one line to the next if another program is also changing the value. SharedGlobal variables are completely "thread safe" in that you can't cause application crashes using them, although you could introduce logic problems in your code if you fail to account for the value changing unexpectedly.
Unique names are encouraged to prevent multiple developers from using the same name and inadvertently overlapping with another program's variable name.
Examples of the use of SharedGlobal variables are:
Dim Test(2) as String SharedGlobal
Redim Test(3) as String SharedGlobal
Redim Preserve Test(4) as String SharedGlobal



Steps required to create an application
To create a standard FCAS application:


1       Create a settings file.
Use FirstClass Designer to create a settings file that contains all the resources that your application will need.
2       Create an ODBC data source.
        (optional)
This is only necessary if your application will be connecting to a database.
3       Create the project.
Use the Project Manager to create the project that will be used to compile your application.
4       Connect to the database.
        (optional)
Connect to the database and its tables if your application will be connecting to a database.
5       Add the forms to the project.
6       Name the fields on the forms.
7       Link the fields to the database columns.
        (optional)
This is only necessary for bound columns database applications.
8       Program the project.
Use the Project Manager to program the event procedures (and connect to databases) in source code modules for the objects on the forms.
Programming a project involves:
•       creating code modules for code that is used throughout the project
• adding code for specific forms
• adding code for specific fields.
9       Test the project.
10      Build the application.
11      Distribute the application.
Install the application in FirstClass.