From Clomosy Docs

No edit summary
No edit summary
Line 80: Line 80:
   //ShowMessage(MyDevice.ContactsList.Text);  
   //ShowMessage(MyDevice.ContactsList.Text);  
     try
     try
    {
       for (i = 0 to MyDevice.ContactsList.Count - 1)
       for (i = 0 to MyDevice.ContactsList.Count - 1)
       {
       {
Line 86: Line 85:
         Memo1.Lines.Add('---');
         Memo1.Lines.Add('---');
       }
       }
    }
     finally
     finally
    {
       MyDevice.ContactsList.Free;
       MyDevice.ContactsList.Free;
     }
     }

Revision as of 07:19, 23 April 2024

The TclDeviceManager component is used to interact with devices. This component allows you to control the properties and functions of devices.
Properties include:

- Vibration
- Battery level
- Access to the phonebook

Usage of the TclDeviceManager component:

Feature Use of Definition
TclDeviceManager MyDevice:TclDeviceManager; Variable is defined.
TclDeviceManager.Create MyDevice:=TclDeviceManager.Create; TclDeviceManager is created on the project.
Vibrate MyDevice.Vibrate(500); It is used to control the vibration feature of the device. In the example, it was vibrated for 500 milliseconds.
BatteryStatus MyDevice.BatteryStatus Indicates the battery level of the device.
GetAddressBookContacts MyDevice.GetAddressBookContacts('ConList'); Provides access to the phone book of the device. In the example 'ConList' is a procedure.
ContactsList MyDevice.ContactsList.Text Returns a list representing contacts in the device's address book.
CallOnAfterListProcName MyDevice.CallOnAfterListProcName Specifies the name of the procedure to be called after obtaining the list of phonebook contacts on the device.

You can examine how these properties are used with an example. In the example, names retrieved from the phonebook are listed in a Memo.

Example:

Base Syntax
var
 MyDevice:TclDeviceManager;
 i : Integer;
 Memo1 : TclMemo;
 MyForm : TclForm;
 procedure ConList;
 begin
   //ShowMessage(MyDevice.ContactsList.Text); 
   try
     for i := 0 to MyDevice.ContactsList.Count - 1 do
     begin
      Memo1.Lines.Add('Name: ' + Clomosy.StringListItemString(MyDevice.ContactsList,i));
      Memo1.Lines.Add('---');
     end;
   finally
     MyDevice.ContactsList.Free;
   end;
 End;
begin
 MyForm := TclForm.Create(Self);

 Memo1 := MyForm.AddNewMemo(MyForm,'Memo1','');
 Memo1.Align := alClient;
 Memo1.Margins.Left:= 10;
 Memo1.Margins.Right:= 10; 
 Memo1.Margins.Top:= 10;
 Memo1.Margins.Bottom:= 10;
 Memo1.ReadOnly := True;
 Memo1.TextSettings.WordWrap := True;

 MyDevice:=TclDeviceManager.Create;
 ShowMessage(MyDevice.BatteryStatus);
 MyDevice.Vibrate(500);
 MyDevice.GetAddressBookContacts('ConList');
 ShowMessage('List Name: '+MyDevice.CallOnAfterListProcName);

 MyForm.Run;
End;
TRObject Syntax
 var
   MyDevice:TclDeviceManager;
   i : Integer;
   Memo1 : TclMemo;
   MyForm : TclForm;
 void ConList;
 {
 //ShowMessage(MyDevice.ContactsList.Text); 
   try
     for (i = 0 to MyDevice.ContactsList.Count - 1)
     {
       Memo1.Lines.Add('Name: ' + Clomosy.StringListItemString(MyDevice.ContactsList,i));
       Memo1.Lines.Add('---');
     }
   finally
     MyDevice.ContactsList.Free;
   }
 }
 {
   MyForm = TclForm.Create(Self);
   
   Memo1 = MyForm.AddNewMemo(MyForm,'Memo1','');
   Memo1.Align = alClient;
   Memo1.Margins.Left= 10;
   Memo1.Margins.Right= 10; 
   Memo1.Margins.Top= 10;
   Memo1.Margins.Bottom= 10;
   Memo1.ReadOnly = True;
   Memo1.TextSettings.WordWrap = True;
   
   MyDevice=TclDeviceManager.Create;
   ShowMessage(MyDevice.BatteryStatus);
   MyDevice.Vibrate(500);
   MyDevice.GetAddressBookContacts('ConList');
   ShowMessage('List Name: '+MyDevice.CallOnAfterListProcName);
   
   MyForm.Run;
 }