You can create a class under Smart Mobile Studio the exact same way as you would under Embarcadero Delphi or free-pascal. Just like ordinary object pascal, classes, custom types and functions are stored in a unit file. Below is an example of a very simple class which has one public member:
[sourcecode language=”delphi”]
unit myobject;
interface
uses w3system;
type
TMyObject = Class(TObject)
public
procedure dosomething;
End;
implementation
procedure TMyObject.dosomething;
Begin
w3_showmessage(‘you called me’);
end;
end.
[/sourcecode]
To add a new unit to your project, click the “add unit” button in the IDE, or select add unit from the project menu. You can then proceed to type in the code you want. By default the IDE provides some skeleton code for your unit, so you don’t have to type everything.
To use the unit you have just created – simply add the name of the unit to the uses section in an already existing unit. All unit have a uses section which makes the code in other units visible to that particular unit.