From Clomosy Docs

No edit summary
No edit summary
 
(6 intermediate revisions by one other user not shown)
Line 5: Line 5:
: - Access to the phonebook
: - Access to the phonebook


Usage of the TclDeviceManager component:
<div class="table-responsive">
 
{| class="wikitable" style="border: 2px solid #c3d7e0"
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition  
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition  
|-
|-
|TclDeviceManager ||MyDevice:TclDeviceManager; ||Variable is defined.  
|TclDeviceManager ||DeviceManager1:TclDeviceManager; ||Variable is defined.  
|-
|-
|TclDeviceManager.Create ||MyDevice:=TclDeviceManager.Create; ||TclDeviceManager is created on the project.  
|TclDeviceManager.Create ||DeviceManager1 = 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.  
|Vibrate ||DeviceManager1.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.
|BatteryStatus ||DeviceManager1.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.
|GetAddressBookContacts ||DeviceManager1.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.
|ContactsList ||DeviceManager1.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.
|CallOnAfterListProcName ||DeviceManager1.CallOnAfterListProcName ||Specifies the name of the procedure to be called after obtaining the list of phonebook contacts on the device.
|}
|}
</div>


You can examine how these properties are used with an example. In the example, names retrieved from the phonebook are listed in a Memo.
<b>Example</b><br>


'''Example:'''<br>
In the example, vibration and battery level are displayed, and names retrieved from the phonebook are listed in a Memo.<br>
  '''var'''
 
  MyDevice:TclDeviceManager;
<pre>
  i : Integer;
  var
  Memo1 : TclMemo;
  MyDevice:TclDeviceManager;
  MyForm : TclForm;
  i : Integer;
  '''procedure ConList;'''
  Memo1 : TclMemo;
  '''begin'''
  MyForm : TclForm;
    //ShowMessage(MyDevice.ContactsList.Text);  
void ConList;
    try
{
      for i := 0 to MyDevice.ContactsList.Count - 1 do
//ShowMessage(MyDevice.ContactsList.Text);  
      begin
  try
    for (i = 0 to MyDevice.ContactsList.Count - 1)
    {
       Memo1.Lines.Add('Name: ' + Clomosy.StringListItemString(MyDevice.ContactsList,i));
       Memo1.Lines.Add('Name: ' + Clomosy.StringListItemString(MyDevice.ContactsList,i));
       Memo1.Lines.Add('---');
       Memo1.Lines.Add('---');
      end;
    }
    finally
  finally
      MyDevice.ContactsList.Free;
    MyDevice.ContactsList.Free;
    end;
  }
  '''End;'''
}
  '''begin'''
  {
  MyForm := TclForm.Create(Self);
  MyForm = TclForm.Create(Self);
 
  Memo1 := MyForm.AddNewMemo(MyForm,'Memo1',<nowiki>''</nowiki>);
  Memo1 = MyForm.AddNewMemo(MyForm,'Memo1','');
  Memo1.Align := alClient;
  Memo1.Align = alClient;
  Memo1.Margins.Left:= 10;
  Memo1.Margins.Left= 10;
  Memo1.Margins.Right:= 10;  
  Memo1.Margins.Right= 10;  
  Memo1.Margins.Top:= 10;
  Memo1.Margins.Top= 10;
  Memo1.Margins.Bottom:= 10;
  Memo1.Margins.Bottom= 10;
  Memo1.ReadOnly := True;
  Memo1.ReadOnly = True;
  Memo1.TextSettings.WordWrap := True;
  Memo1.TextSettings.WordWrap = True;
 
  MyDevice:=TclDeviceManager.Create;
  MyDevice=TclDeviceManager.Create;
  ShowMessage(MyDevice.BatteryStatus);
  ShowMessage(MyDevice.BatteryStatus);
  MyDevice.Vibrate(500);
  MyDevice.Vibrate(500);
  MyDevice.GetAddressBookContacts('ConList');
  MyDevice.GetAddressBookContacts('ConList');
  ShowMessage('List Name: '+MyDevice.CallOnAfterListProcName);
  ShowMessage('List Name: '+MyDevice.CallOnAfterListProcName);
 
  MyForm.Run;
  MyForm.Run;
  '''End;'''
  }
</pre>
 
<h2> See Also </h2>
* [[Components]]
* [[Object Properties]]
* [[AddNewEvent]]
{{#seo:|description=Explore TclDeviceManager on Clomosy! Learn how to manage and control devices in your applications using the TclDeviceManager.}}

Latest revision as of 07:25, 24 December 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
Feature Use of Definition
TclDeviceManager DeviceManager1:TclDeviceManager; Variable is defined.
TclDeviceManager.Create DeviceManager1 = TclDeviceManager.Create; TclDeviceManager is created on the project.
Vibrate DeviceManager1.Vibrate(500); It is used to control the vibration feature of the device. In the example, it was vibrated for 500 milliseconds.
BatteryStatus DeviceManager1.BatteryStatus Indicates the battery level of the device.
GetAddressBookContacts DeviceManager1.GetAddressBookContacts('ConList'); Provides access to the phone book of the device. In the example 'ConList' is a procedure.
ContactsList DeviceManager1.ContactsList.Text Returns a list representing contacts in the device's address book.
CallOnAfterListProcName DeviceManager1.CallOnAfterListProcName Specifies the name of the procedure to be called after obtaining the list of phonebook contacts on the device.

Example

In the example, vibration and battery level are displayed, and names retrieved from the phonebook are listed in a Memo.

 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;
 }

See Also