Quantcast
Channel: Planet Object Pascal
Viewing all 1725 articles
Browse latest View live

Firebird News: Database .NET 8.2 released with many new features

$
0
0
Database .NET is an innovative, powerful and intuitive multiple database management tool. You can Browse objects, Design tables, Edit rows, Export data and Run queries with a consistent interface. What’s New (2013/04/08) Added User-Defined Data Types(Domains) support Added Goto Line and Goto Row support Added support for Jump list and Overlay Icons Added Value for [...]

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

Last quarter, 11 issues of Micro Cornucopia appeared on BitSavers including the final May 1990 issue.

This month, another 7 issues appeared, most of which cover a form of Pascal in one or more of the articles and advertisements:

A fun thing to notice are the advertisements for Modula-2. Logitech Modula-2. Yes though the Logitech Wikipedia page does not mention it at all, Logitech didn’t only sell mice, keyboards and web-cams. They had more products. Being Swiss, they were big in Modula-2.

The only issues still to be scanned are #28 till #32.

–jeroen

via: New Micro Cornucopia issues on BitSavers including the Final May 1990 issue « The Wiert Corner – irregular stream of stuff.


Filed under: Assembly Language, C, C++, Delphi, Development, Pascal, Software Development, Turbo Assembler, Turbo Pascal, x86 Tagged: computer, media, research, science, technology

The Wiert Corner - irregular stream of stuff: jpluimers

DelphiTools.info: COM connector spring cleanup

$
0
0

ConnectorsDWScript COM Connector has just received a spring cleanup, as it had grown a bit mouldy over the last years.  The COM Connector optionally gives scripts direct access to ActiveX and COM objects.

As part of the cleanup, it now support IEnumVARIANT and ComVariantArray can now be enumerated as well with “for in“.

In practice it means you can now use it to query WMI information f.i., as an illustration the following code will run a WQL query and print the name of the processor running the system:

const wbemFlagForwardOnly = $00000020;

var locator := CreateOleObject('WbemScripting.SWbemLocator');
var service := locator.ConnectServer('localhost', 'root\CIMV2', '', '');
var objectSet := service.ExecQuery('Select Name from Win32_Processor',
                                   'WQL', wbemFlagForwardOnly);

forvar item in objectSet do
   PrintLn(item.Properties_.Item('Name').Value);

And speaking of WMI, Rodrigo RUZ maintains a lot of useful WMI queries on his The Road To Delphi blog.

twm’s blog: setfacl woes

$
0
0

Ever since I switched my Linux server to using ACLs (access control lists) for advanced access rights management I have struggled with rights being set too restrictive on new directories and files. Now it seems that I have solved the issue and this post is meant to remind me how to change the whole directory tree to the rights I want it to have:

sudo setfacl -Rm d:u::rwX,u::rwX,d:g::rwX,g::rwX,d:o:rX,o:rX directoryname

This recursively sets default and actual rights for directoryname and subdirectories as:

  • users: rw for files and directoryies, x for directories only
  • groups: the same
  • others: r for files and directories, x for directories only

I really hope that this is the last time I have to troubleshoot access rights issues. I want to concentrate on developing software rather than administrating bloody servers.

DelphiTools.info: DWScript showcase: AquaSoft SlideShow

$
0
0

Answering the call for showcases, Steffen Binas prepared a very nice set of screenshots for AquaSoft‘s Slide Show impressive product, which went far beyond the minimal requirement, so I’m posting a full-blown article about it. Following is the presentation of their software and how DWScript is used inside it.

When you need a powerful showcase I’d bet AquaSoft SlideShow is the one: http://www.aquasoft.de/diashow.as (an english website for version 8 is coming soon).

AquaSoft_ScreenshotDS8

Despite the simple name of the application it’s very powerful, just have look at the trailer video created completely with it.

We implemented an API to manipulate the slideshow before and during playing, we generate GUI using scripts and implemented an IDE with debugger and code completion. We implemented a powerful publishing system to export Delphi interfaces to scripting space via Attributes and RTTI.
Scripted context menus

Scripted context menus

The scripting system is intended to be used mainly by the developers and preset designers but we provide all the tools users too.

Script-based presets

Script-based presets

Our Interface based API can be found here (German only): http://wiki.aquasoft.de/wiki/index.php/Dokumentation_der_Scripting-API

AquaSoft Scripting IDE

AquaSoft Scripting IDE

How scripting is used:

  • build intelligent presets which generate parts of the slideshow out of more complex templates.
  • generate basic GUI for presets (e.g. Animated Path)
  • allow execution of HLSL shaders, build their GUI and calculate their parameters
  • generate context menu entries for SlideShowObjects
  • manipulate bitmaps
Scripted GUI

Scripted GUI

Another product is AquaSoft WebShow 4 which is a tool to create web galleries out of photos and videos. DWScript is used here in its original manner using the HTML Filter to mix pascal code with html. Later we used more and more an HTMLBuilder class with fluent interface written completely in DWScript to avoid the html fragments mixed in the templates.

Scripted Web Templates

Scripted Web Templates

The templates are created object orientated and use inheritance. DWScript was a replacement for an own scripting language which was used in earlier versions. WebShow 4 is unfortunatelly not completely ready yet as it only has three templates included but is already public as the web wizard shipped together with AquaSoft SlideShow 8.

The road to Delphi: How distinguish when Windows was installed in Legacy BIOS or UEFI mode using Delphi?

$
0
0

As part of the TSMBIOS project, I needed a method to distinguish when Windows was installed in Legacy BIOS or UEFI mode. The solution was provided by the GetFirmwareEnvironmentVariable function.

The msdn documentation states

Firmware variables are not supported on a legacy BIOS-based system. The GetFirmwareEnvironmentVariable function will always fail on a legacy BIOS-based system, or if Windows was installed using legacy BIOS on a system that supports both legacy BIOS and UEFI. To identify these conditions, call the function with a dummy firmware environment name such as an empty string (“”) for the lpName parameter and a dummy GUID such as “{00000000-0000-0000-0000-000000000000}” for the lpGuid parameter. On a legacy BIOS-based system, or on a system that supports both legacy BIOS and UEFI where Windows was installed using legacy BIOS, the function will fail with ERROR_INVALID_FUNCTION. On a UEFI-based system, the function will fail with an error specific to the firmware, such as ERROR_NOACCESS, to indicate that the dummy GUID namespace does not exist.
.

So the Delphi code to detect such condition will be something like so

{$APPTYPE CONSOLE}

uses
  Windows,
  SysUtils;

function GetFirmwareEnvironmentVariableA(lpName, lpGuid: LPCSTR; pBuffer: Pointer;
  nSize: DWORD): DWORD; stdcall; external kernel32 name 'GetFirmwareEnvironmentVariableA';

begin
  try
    GetFirmwareEnvironmentVariableA('','{00000000-0000-0000-0000-000000000000}', nil,0);
    if (GetLastError = ERROR_INVALID_FUNCTION) then
      Writeln('Legacy BIOS')
    else
      Writeln('UEFI Boot Mode');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;
end.

The road to Delphi: Added Linux support to the TSMBIOS Project

$
0
0

Great news for the Free Pascal developers, I just added Linux support to the TSMBIOS project.

Linux_TSMbios

Note : The TSMBIOS read the SMBIOS info using the /dev/mem device file  which provides access to system physical memory, so the code must be executed using a user with the proper permissions.



The road to Delphi: Delphi XE3 Vcl Styles Additions

The road to Delphi: How customize the fonts of a TActionMainMenuBar and TPopupActionBar with the Vcl Styles Enabled

$
0
0

This week I received two emails from different Delphi developers asking about : How customize the fonts of a TActionMainMenuBar and TPopupActionBar with the Vcl Styles Enabled? Also a question about the same topic was asked in StackOverflow.

This post shows how this task can be done.

In order to change the font and size of a TActionMainMenuBar and a TPopupActionBar in a VCL application you must use the Screen.MenuFont property like so.

  Screen.MenuFont.Name := 'Impact';
  Screen.MenuFont.Size := 12;

But if the Vcl Styles are enabled these changes are not reflected (This is because the Vcl Styles uses the fonts defined in style file).

Now if you want change the font type or font size of the Vcl Styles elements related to the menus like MenuItemTextNormal, MenuItemTextHot and so on, you will use the Style Designer and set font values which you want.

But unfortunately this will not work either, I mean even if you edit the fonts of the Vcl Style file, the changes are not reflected in the Menus components (or others controls). The reason for this is that the Vcl Styles Engine ignores the fonts types and font size defined in the style file. and just use the font color value to draw the text of the controls.

Note : The font used by the Vcl Styles is Tahoma and the Size is 8.

So what is the solution for customize the font of a TActionMainMenuBar component? A possible workaround is create a new Action Bar Style and also create a new TCustomMenuItem and TCustomMenuButton to override the DrawTextmethod and draw your self the menu text using the Screen.MenuFont values, the good news are which since now, you can find a implementation of a new Action Bar Style in the Vcl.PlatformVclStylesActnCtrls unit (which is part of the Vcl Styles Utils project) which allows you to modify the font of the TActionMainMenuBar and TPopupActionBar components.

So to use this new Action Bar Style, just add the Vcl.PlatformVclStylesActnCtrls unit to your project and then assign the new style to your Action Manager like so :

  ActionManager1.Style:=PlatformVclStylesStyle;

And now when you run your app the TActionMainMenuBar and TPopupActionBar will use the font defined in the Screen.MenuFont property.


The road to Delphi: Exploring Delphi XE3 – Accesing Windows Sensors from VCL (and Firemonkey)

$
0
0

Delphi XE3 includes support for sensors in OSX and Windows, the classes and types necessaries to access such devices are defined as abstract classes in the System.Sensors unit and implemented in the System.Mac.Sensors unit for OSX and System.Win.Sensors unit for Windows. This article will focus in the Windows side implementation.

Windows 7 introduces the Sensor and Location API, which unifies the access to hardware devices like GPS, Light Sensors, Biometric Sensors and so on. Avoiding the need of use a specific dlls or SDK to control the sensor devices. this API is condensed on these files which are part of the Windows 7 Software Development Kit (SDK).

File nameDescription
Sensorsapi.hThe main header file for the Sensor API. This header file contains the interface definitions.
Sensors.hThe header file that contains definitions of platform-defined constants.
Initguid.hThe header file that contains definitions for controlling GUID initialization.{
FunctionDiscoveryKeys.hThe header file that defines device ID property keys that are required when you connect to logical sensors.
Sensorsapi.libA static library that contains GUID definitions for the Sensor API.
PortableDeviceGuids.libA static library that contains GUID definitions for Windows Portable Devices objects.

All these headers was translated by Embarcadero and included as part of the RTL of the Delphi XE3, these are the units which contains such translations Winapi.Portabledevicetypes, Winapi.Sensors, Winapi.Sensorsapi, Winapi.Locationapi. Fortunately an additional set of classes was added to wrap the sensors API, these classes are defined and implemented in the System.Sensors and System.Win.Sensors units. So you don’t need access directly interfaces like ISensor or ISensorManager to gain access to the sensors.

Enumerating Sensors

In order to gain access to the sensors you must get an instance to the TSensorManager class and then call the Activate method, from here you can iterate over the Sensors property or use the GetSensorsByCategory method to get an array of TSensor objects filtered by an TSensorCategory.

var
  LManager : TSensorManager;
  LSensors : TSensorArray;
  LSensor  : TCustomSensor;
begin
  LManager := TSensorManager.Current;
  LManager.Activate;
  try
    LSensors  := LManager.GetSensorsByCategory(TSensorCategory.Location);
    for LSensor in LSensors do
    begin
      //do something
    end;
  finally
    LManager.Deactivate;
  end;
end;

All the sensors share a common set of properties like the Manufacturer, Model, Serial number and so on. So extending the above code you can access such properties on this way :

var
  LManager : TSensorManager;
  LSensors : TSensorArray;
  LSensor  : TCustomSensor;
begin
  LManager := TSensorManager.Current;
  LManager.Activate;
  try
    LSensors  := LManager.GetSensorsByCategory(TSensorCategory.Location);
    for LSensor in LSensors do
    begin
      Writeln(Format('Description  : %s', [LSensor.Description]));
      Writeln(Format('Manufacturer : %s', [LSensor.Manufacturer]));
      Writeln(Format('Model        : %s', [LSensor.Model]));
      Writeln(Format('Serial No    : %s', [LSensor.SerialNo]));
      Writeln(Format('State        : %s', [GetEnumName(TypeInfo(TSensorState),integer(LSensor.State))]));
      Writeln(Format('TimeStamp    : %s', [DatetoStr(LSensor.TimeStamp)]));
      Writeln(Format('Unique ID    : %s', [LSensor.UniqueID]));
    end;
  finally
    LManager.Deactivate;
  end;
end;

Now depending of the sensor category, you must cast the TCustomSensor to the proper specific class, in this case we will use the TCustomLocationSensor class.

var
  LManager : TSensorManager;
  LSensors : TSensorArray;
  LSensor  : TCustomSensor;
  LLocationSensor          : TCustomLocationSensor;
begin
  LManager := TSensorManager.Current;
  LManager.Activate;
  try
    LSensors  := LManager.GetSensorsByCategory(TSensorCategory.Location);
    for LSensor in LSensors do
    begin
      Writeln(Format('Description  : %s', [LSensor.Description]));
      Writeln(Format('Manufacturer : %s', [LSensor.Manufacturer]));
      Writeln(Format('Model        : %s', [LSensor.Model]));
      Writeln(Format('Serial No    : %s', [LSensor.SerialNo]));
      Writeln(Format('State        : %s', [GetEnumName(TypeInfo(TSensorState),integer(LSensor.State))]));
      Writeln(Format('TimeStamp    : %s', [DatetoStr(LSensor.TimeStamp)]));
      Writeln(Format('Unique ID    : %s', [LSensor.UniqueID]));

        LLocationSensor:=LSensor as TCustomLocationSensor;
        LLocationSensor.Start;
        try
          Writeln(Format('Sensor Type       : %s', [GetEnumName(TypeInfo(TLocationSensorType),integer(LLocationSensor.SensorType))]));
          Writeln(Format('Authorized        : %s', [GetEnumName(TypeInfo(TAuthorizationType),integer(LLocationSensor.Authorized))]));
          Writeln(Format('Accuracy          : %n', [LLocationSensor.Accuracy]));
          Writeln(Format('Distance          : %n', [LLocationSensor.Distance]));
          Writeln(Format('Power Consumption : %s', [GetEnumName(TypeInfo(TPowerConsumption),integer(LLocationSensor.PowerConsumption))]));
          Writeln(Format('Location Change   : %s', [GetEnumName(TypeInfo(TLocationChangeType),integer(LLocationSensor.LocationChange))]));
          if TCustomLocationSensor.TProperty.Latitude in  LLocationSensor.AvailableProperties then
          Writeln(Format('Latitude          : %n', [LLocationSensor.Latitude]));
          if TCustomLocationSensor.TProperty.Longitude in  LLocationSensor.AvailableProperties then
          Writeln(Format('Longitude         : %n', [LLocationSensor.Longitude]));
          if TCustomLocationSensor.TProperty.ErrorRadius in  LLocationSensor.AvailableProperties then
          Writeln(Format('Error Radius      : %n', [LLocationSensor.ErrorRadius]));
          if TCustomLocationSensor.TProperty.Altitude in  LLocationSensor.AvailableProperties then
          Writeln(Format('Altitude          : %n', [LLocationSensor.Altitude]));
          if TCustomLocationSensor.TProperty.Speed in  LLocationSensor.AvailableProperties then
          Writeln(Format('Speed             : %n', [LLocationSensor.Speed]));
          if TCustomLocationSensor.TProperty.TrueHeading in  LLocationSensor.AvailableProperties then
          Writeln(Format('True Heading      : %n', [LLocationSensor.TrueHeading]));
          if TCustomLocationSensor.TProperty.MagneticHeading in  LLocationSensor.AvailableProperties then
          Writeln(Format('Magnetic Heading  : %n', [LLocationSensor.MagneticHeading]));
          if TCustomLocationSensor.TProperty.Address1 in  LLocationSensor.AvailableProperties then
          Writeln(Format('Address1          : %s', [LLocationSensor.Address1]));
          if TCustomLocationSensor.TProperty.Address2 in  LLocationSensor.AvailableProperties then
          Writeln(Format('Address2          : %s', [LLocationSensor.Address2]));
          if TCustomLocationSensor.TProperty.City in  LLocationSensor.AvailableProperties then
          Writeln(Format('City              : %s', [LLocationSensor.City]));
          if TCustomLocationSensor.TProperty.StateProvince in  LLocationSensor.AvailableProperties then
          Writeln(Format('State/Province    : %s', [LLocationSensor.StateProvince]));
          if TCustomLocationSensor.TProperty.PostalCode in  LLocationSensor.AvailableProperties then
          Writeln(Format('Postal Code       : %s', [LLocationSensor.PostalCode]));
          if TCustomLocationSensor.TProperty.CountryRegion in  LLocationSensor.AvailableProperties then
          Writeln(Format('Country Region    : %s', [LLocationSensor.CountryRegion]));
        finally
          LLocationSensor.Stop;
        end;
        Writeln;
    end;
  finally
    LManager.Deactivate;
  end;

end;

Not all the properties exposed by the Windows sensors and Location API are mapped directly in the TCustomSensors class, so to access this additional data you can use the HasCustomData and CustomData indexed properties and use one of the values defined in the Winapi.Sensors unit which is the translation of the Sensors.h header file.

  if LLocationSensor.HasCustomData[SENSOR_DATA_TYPE_SATELLITES_USED_COUNT]  then
    Writeln(Format('Satellites used : %d', [ Integer(LLocationSensor.CustomData[SENSOR_DATA_TYPE_SATELLITES_USED_COUNT])]));

Sample Application

Check this sample console application which enumerates all the sensors and properties.

{$APPTYPE CONSOLE}

uses
  System.TypInfo,
  System.Sensors,
  System.SysUtils;

procedure EnumerateSensors;
var
  LManager : TSensorManager;
  LCustomLocationSensor          : TCustomLocationSensor;
  LCustomLightSensor             : TCustomLightSensor;
  LCustomEnvironmentalSensor     : TCustomEnvironmentalSensor;
  LCustomMotionSensor            : TCustomMotionSensor;
  LCustomOrientationSensor       : TCustomOrientationSensor;
  LCustomMechanicalSensor        : TCustomMechanicalSensor;
  LCustomElectricalSensor        : TCustomElectricalSensor;
  LCustomBiometricSensor         : TCustomBiometricSensor;
  LCustomScannerSensor           : TCustomScannerSensor;
  LSensor  : TCustomSensor;
  i        : Integer;
begin
  LManager := TSensorManager.Current;
  LManager.Activate;
  //LSensors  := LManager.GetSensorsByCategory(TSensorCategory.Location);
  if LManager.Count > 0 then
  for i := 0 to LManager.Count-1 do
  begin
    Writeln(Format('Sensor %d',[i+1]));
    Writeln('--------');

    LSensor:= LManager.Sensors[i];
    Writeln(Format('Category     : %s', [GetEnumName(TypeInfo(TSensorCategory),integer(LSensor.Category))]));
    Writeln(Format('Description  : %s', [LSensor.Description]));
    Writeln(Format('Manufacturer : %s', [LSensor.Manufacturer]));
    Writeln(Format('Model        : %s', [LSensor.Model]));
    Writeln(Format('Serial No    : %s', [LSensor.SerialNo]));
    Writeln(Format('State        : %s', [GetEnumName(TypeInfo(TSensorState),integer(LSensor.State))]));
    Writeln(Format('TimeStamp    : %s', [DatetoStr(LSensor.TimeStamp)]));
    Writeln(Format('Unique ID    : %s', [LSensor.UniqueID]));

    case LSensor.Category of

      TSensorCategory.Location :
      begin
        LCustomLocationSensor:=LSensor as TCustomLocationSensor;
        LCustomLocationSensor.Start;
        Writeln(Format('Sensor Type       : %s', [GetEnumName(TypeInfo(TLocationSensorType),integer(LCustomLocationSensor.SensorType))]));
        Writeln(Format('Authorized        : %s', [GetEnumName(TypeInfo(TAuthorizationType),integer(LCustomLocationSensor.Authorized))]));
        Writeln(Format('Accuracy          : %n', [LCustomLocationSensor.Accuracy]));
        Writeln(Format('Distance          : %n', [LCustomLocationSensor.Distance]));
        Writeln(Format('Power Consumption : %s', [GetEnumName(TypeInfo(TPowerConsumption),integer(LCustomLocationSensor.PowerConsumption))]));
        Writeln(Format('Location Change   : %s', [GetEnumName(TypeInfo(TLocationChangeType),integer(LCustomLocationSensor.LocationChange))]));
        Writeln(Format('Latitude          : %n', [LCustomLocationSensor.Latitude]));
        Writeln(Format('Longitude         : %n', [LCustomLocationSensor.Longitude]));
        Writeln(Format('Longitude         : %n', [LCustomLocationSensor.Longitude]));
        Writeln(Format('Error Radius      : %n', [LCustomLocationSensor.ErrorRadius]));
        Writeln(Format('Altitude          : %n', [LCustomLocationSensor.Altitude]));
        Writeln(Format('Speed             : %n', [LCustomLocationSensor.Speed]));
        Writeln(Format('True Heading      : %n', [LCustomLocationSensor.TrueHeading]));
        Writeln(Format('Magnetic Heading  : %n', [LCustomLocationSensor.MagneticHeading]));
        Writeln(Format('Address1          : %s', [LCustomLocationSensor.Address1]));
        Writeln(Format('Address2          : %s', [LCustomLocationSensor.Address2]));
        Writeln(Format('City              : %s', [LCustomLocationSensor.City]));
        Writeln(Format('State/Province    : %s', [LCustomLocationSensor.StateProvince]));
        Writeln(Format('Postal Code       : %s', [LCustomLocationSensor.PostalCode]));
        Writeln(Format('Country Region    : %s', [LCustomLocationSensor.CountryRegion]));
        LCustomLocationSensor.Stop;
      end;

      TSensorCategory.Light :
      begin
        LCustomLightSensor:=LSensor as TCustomLightSensor;
        Writeln(Format('Lux          : %n', [LCustomLightSensor.Lux]));
        Writeln(Format('Temperature  : %n', [LCustomLightSensor.Temperature]));
        Writeln(Format('Chromacity   : %n', [LCustomLightSensor.Chromacity]));
        Writeln(Format('Sensor Type  : %s', [GetEnumName(TypeInfo(TLightSensorType),integer(LCustomLightSensor.SensorType))]));
      end;

      TSensorCategory.Environmental :
      begin
        LCustomEnvironmentalSensor:= LSensor as TCustomEnvironmentalSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TEnvironmentalSensorType),integer(LCustomEnvironmentalSensor.SensorType))]));
        Writeln(Format('Temperature    : %n', [LCustomEnvironmentalSensor.Temperature]));
        Writeln(Format('Pressure       : %n', [LCustomEnvironmentalSensor.Pressure]));
        Writeln(Format('Humidity       : %n', [LCustomEnvironmentalSensor.Humidity]));
        Writeln(Format('Wind Direction : %n', [LCustomEnvironmentalSensor.WindDirection]));
        Writeln(Format('Wind Speed     : %n', [LCustomEnvironmentalSensor.WindSpeed]));
      end;

      TSensorCategory.Motion :
      begin
        LCustomMotionSensor:= LSensor as TCustomMotionSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TMotionSensorType),integer(LCustomMotionSensor.SensorType))]));
        Writeln(Format('Acceleration X : %n', [LCustomMotionSensor.AccelerationX]));
        Writeln(Format('Acceleration Y : %n', [LCustomMotionSensor.AccelerationY]));
        Writeln(Format('Acceleration Z : %n', [LCustomMotionSensor.AccelerationZ]));
        Writeln(Format('Angle Accel. X : %n', [LCustomMotionSensor.AngleAccelX]));
        Writeln(Format('Angle Accel. Y : %n', [LCustomMotionSensor.AngleAccelY]));
        Writeln(Format('Angle Accel. Z : %n', [LCustomMotionSensor.AngleAccelZ]));
        Writeln(Format('Motion         : %n', [LCustomMotionSensor.Motion]));
        Writeln(Format('Speed          : %n', [LCustomMotionSensor.Speed]));
        Writeln(Format('Update Interval: %n', [LCustomMotionSensor.UpdateInterval]));
      end;

      TSensorCategory.Orientation :
      begin
        LCustomOrientationSensor:= LSensor as TCustomOrientationSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TOrientationSensorType),integer(LCustomOrientationSensor.SensorType))]));
        Writeln(Format('Tilt X         : %n', [LCustomOrientationSensor.TiltX]));
        Writeln(Format('Tilt Y         : %n', [LCustomOrientationSensor.TiltY]));
        Writeln(Format('Tilt Z         : %n', [LCustomOrientationSensor.TiltZ]));
        Writeln(Format('Distance X     : %n', [LCustomOrientationSensor.DistanceX]));
        Writeln(Format('Distance Y     : %n', [LCustomOrientationSensor.DistanceY]));
        Writeln(Format('Distance Z     : %n', [LCustomOrientationSensor.DistanceZ]));
        Writeln(Format('Heading X      : %n', [LCustomOrientationSensor.HeadingX]));
        Writeln(Format('Heading Y      : %n', [LCustomOrientationSensor.HeadingY]));
        Writeln(Format('Heading Z      : %n', [LCustomOrientationSensor.HeadingZ]));
        Writeln(Format('Mag. Heading   : %n', [LCustomOrientationSensor.MagHeading]));
        Writeln(Format('True Heading   : %n', [LCustomOrientationSensor.TrueHeading]));
        Writeln(Format('Comp.Heading   : %n', [LCustomOrientationSensor.CompMagHeading]));
        Writeln(Format('Comp True Head : %n', [LCustomOrientationSensor.CompTrueHeading]));
      end;

      TSensorCategory.Mechanical :
      begin
        LCustomMechanicalSensor:= LSensor as TCustomMechanicalSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TMechanicalSensorType),integer(LCustomMechanicalSensor.SensorType))]));
        Writeln(Format('Switch State   : %s', [BoolToStr(LCustomMechanicalSensor.SwitchState, True)]));
        Writeln(Format('Switch Array State : %d', [LCustomMechanicalSensor.SwitchArrayState]));
        Writeln(Format('Multi Value State  : %n', [LCustomMechanicalSensor.MultiValueState]));
        Writeln(Format('Force              : %n', [LCustomMechanicalSensor.Force]));
        Writeln(Format('Abs. Pressure      : %n', [LCustomMechanicalSensor.AbsPressure]));
        Writeln(Format('Gauge Pressure     : %n', [LCustomMechanicalSensor.GaugePressure]));
        Writeln(Format('Strain             : %n', [LCustomMechanicalSensor.Strain]));
        Writeln(Format('Weight             : %n', [LCustomMechanicalSensor.Weight]));
      end;

      TSensorCategory.Electrical :
      begin
        LCustomElectricalSensor:= LSensor as TCustomElectricalSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TElectricalSensorType),integer(LCustomElectricalSensor.SensorType))]));
        Writeln(Format('Capacitance    : %n', [LCustomElectricalSensor.Capacitance]));
        Writeln(Format('Resistance     : %n', [LCustomElectricalSensor.Resistance]));
        Writeln(Format('Inductance     : %n', [LCustomElectricalSensor.Inductance]));
        Writeln(Format('Current        : %n', [LCustomElectricalSensor.Current]));
        Writeln(Format('Voltage        : %n', [LCustomElectricalSensor.Voltage]));
        Writeln(Format('Power          : %n', [LCustomElectricalSensor.Power]));
      end;

      TSensorCategory.Biometric :
      begin
        LCustomBiometricSensor:= LSensor as TCustomBiometricSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TBiometricSensorType),integer(LCustomBiometricSensor.SensorType))]));
        Writeln(Format('Human Proximity: %n', [LCustomBiometricSensor.HumanProximity]));
        Writeln(Format('Human Presense : %s', [BoolToStr(LCustomBiometricSensor.HumanPresense, True)]));
        Writeln(Format('Touch          : %s', [BoolToStr(LCustomBiometricSensor.Touch, True)]));
      end;

      TSensorCategory.Scanner :
      begin
        LCustomScannerSensor:= LSensor as TCustomScannerSensor;
        Writeln(Format('Sensor Type    : %s', [GetEnumName(TypeInfo(TScannerSensorType),integer(LCustomScannerSensor.SensorType))]));
        Writeln(Format('Human Proximity: %d', [LCustomScannerSensor.RFIDTag]));
        Writeln(Format('Barcode Data   : %s', [LCustomScannerSensor.BarcodeData]));
      end;

    end;
    Writeln;
  end
  else
   Writeln('Not sensors was found');
  LManager.Deactivate;
end;

begin
  try
    EnumerateSensors;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;
end.

Virtual Sensors

If you don’t have sensors in your machine you can play with these virtual sensors.


The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

For my research queue:

I should look at the below ConnectionStrings to access dBase with ADO from Delphi, If I ever need to do that.

Thanks Cromulent for asking, Nelson for editing and Pieter for answering:

Microsoft dBase ODBC driver

Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;OLE DB Services = -1;Extended Properties=dBase IV;Dbq=c:\mypath

doing operations like ADOTable1.Open are very fast (good) but GetIndexNames returns nothing (bad).

Microsoft Jet OLEDB 4.0 driver

Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;OLE DB Services=-1;Data Source=c:\mypath

doing operations like ADOTable1.Open are exceedingly slow (bad) while GetIndexNames does return index names the way it should (good).

How do I get both speed and the index info via ADO for the dBase tables?

Microsoft Paradox Driver 7.x

“We use the following connection string which works really well.”

Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="Driver={Microsoft Visual FoxPro Driver};UID=;SourceDB=c:\mypath;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"

–jeroen

via Delphi + ADO + dBase – Stack Overflow.


Filed under: Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development

Firebird News: Firebird Python driver FDB release 1.1 is out

$
0
0
FDB release 1.1 is out: http://pypi.python.org/pypi/fdb New Features: - Context Manager for transactions. Bugs Fixed: - http://tracker.firebirdsql.org/browse/PYFB-30

Firebird News: isql documentation update

$
0
0
The manual for isql has been hugely updated, tidied up and is now online at http://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/isql.html for the html and at http://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/Firebird-isql.pdf for the pdf version. If you get an older version that document 0.5 then the cache needs to be flushed. It’s still not fully complete, but it’s a lot further down the line [...]

The Wiert Corner - irregular stream of stuff: jpluimers


Firebird News: PHP 5.5 beta3 is released and pdo_firebird.dll is re-added to builds and ready for testers

$
0
0
The PHP development team announces the release of the 3rd beta of PHP 5.5.0. This release fixes some bugs against beta 2. PHP 5.5.0beta3 is shipped with some bug fixes and improvements. Here is an incomplete list: Drop support for bison < 2.4 when building PHP from GIT source. Fixed bug #54567 (DateTimeZone serialize/unserialize) Fixed [...]

The road to Delphi: Added support to TSMBIOS for SMBIOS 2.8 spec.

$
0
0

A few weeks ago (3 Apr 2013) a new update to the System Management BIOS (SMBIOS) Reference Specification was introduced by the DMTF. So the TSMBIOS project was updated to support the SMBIOS 2.8.

The following changes was added to the 2.8 version:

  • Processor Information (Type 4):
  1. SMBIOSCR00106: processor family name correction (48h)
  2. SMBIOSCR00107: new processor family types
  3. SMBIOSCR00108: new processor family type
  4. SMBIOSCR00110: correct typo in table 24 (processor upgrade)
  5. SMBIOSCR00118: new processor family types
  6. SMBIOSCR00121: new processor family type
  7. SMBIOSCR00122: new processor upgrade type
  8. SMBIOSCR00125: add new Intel socket type
  • Memory Device (Type 17):
  1. SMBIOSCR00109: add minimum, maximum and configured voltages
  2. SMBIOSCR00114: add LRDIMM to memory device list
  • Other:
  1. SMBIOSCR00116: correct/clarify structure length fields
  2. SMBIOSCR00120: add new supported processor architectures
  3. SMBIOSCR00123: update referenced specifications
  4. Wording updates for clarity and consistency

Delphi Code Monkey: Programming For Non-Programmers : No Silver Bullets, No Free Lunches.

$
0
0
Programmers tend to be fond of these aphorisms:

  • There Ain't No Such Thing As A Free Lunch (TANSTAAFL) -- Robert Heinlein
  • There Are No Silver Bullets -- Fred Brooks
But leaving aside our cynicism for a while, we also like to imagine local violations of these general-relativity-principles, and one of those areas of perennial optimism is the Programming Language for Non-Programmers.   That was, if you remember far enough back, the impetus for COBOL,  for the Fourth Generation Language (4GL) idea, for tools like PowerBuilder, and Visual Basic, and even, to a certain extent, for Delphi itself.  It resulted in some horrific syntactical nightmares, like AppleScript.

Where Delphi differs from the typical "tools used by people who write code who are not primarily programmers" is that Delphi offers a programming language with elegance, sophistication, and expressive power, that is not broken or hobbled by its syntax.  Not so with just about everything else in that list.   

However, it's time for people to try again, and the newest attempt I've see at "programming for everybody", is called LiveCode, from RunRev.  Go download it now, I'll wait.

What's great about LiveCode? A few things:

  • The core product is free, and is supported by revenues from their tutorial videos (LiveCode Academy) as well as from their sales and support for their premium product.
  • It's cross platform, on Windows, Linux, mobile, and Mac, in fact, it claims to support all the platforms that Delphi still has on the distant future roadmap.
What's not so great about LiveCode?   Well, if you remember back in the good old Borland TurboPascal days, one of the things they did was give you a language introduction in a book, like this:


Inside was a systematic, carefully laid out, and orderly presentation of core concepts, like this:


After a few pages, you begin to grasp a few concepts which you can use over and over again throughout your working life with Pascal.  That's another way of saying that Pascal syntax is orderly, does not try to be english, but is nevertheless readable, and the language is orthogonal to the task it performs.  Now let's look at how coding works in liveCode.  You drop a button and an edit box on a form.  Score for LiveCode is good so far.  You don't need a PhD or a tutorial video to figure out how to use it.  So far, it's as friendly as Visual Basic, C#, and Delphi, and far friendlier than Java.


Double clicking on the Button does not do what it should do. I invoke Visual Basic, Delphi, and C# as three common environments that know what's what. When you double click a button, you should immediately be given the coding context where you will write what happens when the button is pressed.  Instead you have to locate the properties-inspector analog, and find a button that looks like a CD player Play button, and click that and then click Edit Script:


Now we get the code window:


I'm rather proud of myself. It only took me 20 minutes to figure out that the way to set A = B is:

   put"Test2"intoField"Field1"


Let's unpack the concepts here for pedagogical types:

1.  LiveCode owes a debt most of all to 4GLs, AppleScript and HyperCard, and borrows some good ideas from all three.
2.  Put is one of the ways of writing assignments.
3.  The value that is put into something else is the first thing you write. This is backwards to most of us, who learned BASIC,  which has LET A = 5, which has always made perfect sense to me.  Instead we PUT 5 INTO A in this language.  Already, that's too much typing for me.
4. Next let's note that a field has a name "Field1" and that it is a Field, and that unlike a Delphi edit box named Edit1,  we must refer to it always as Field "Field1", not as just Field1.  

I managed to type a few malformed versions of that above line of code that froze the IDE completely, requiring me to Force Quit (end task), like this one:

put "Test" into Field "Field" to "thing"

The above statement passes the grammar-checker in LiveCode, and then goes into the internal works, and does something that wreaks havoc with the internals.  That, my friends, is the steep cliff that all "friendly" languages have lurking at all times.  Designing a grammar is a difficult task, and designing your own language leads to all manner of quirks.   

The lifecycle of these technologies, it seems to me is, well known, and is documented in various places and by various names, most famously as the Hype Cycle:



Am I saying that LiveCode is unimportant? No, far from it. I'm deeply impressed by the author's goal, and I, like them, dream of being able to teach 8 year olds to make video games, or do whatever else they want to do, in a language free of accidental complexity. But I disagree that emulating english with all its ambiguities is the way to do it.  I think that something more like Python is close to ideal for teaching programming. Nevertheless,  Python lacks a true Delphi-style RAD IDE.

There is a very delphi-like free and open source IDE out there that has enough of the basic Delphi IDE features, and enough power in the backing compiler to be most of what I want, but I still think Pascal is not as friendly as it could be, and so I have some hope still for LiveCode.  Since it's open source, I've been wondering if I could hack a bit on their language choices, and try to do things like this:

  • Let users pick items and combine them using menus and toolbars that will result in code templates being generated, for common tasks like variable declarations and assignment, looping, and conditional checks.
  • Let users write in a simple declarative style without line-noise or overhead:
       Field1 = "test"
  • When users type something that is not understood, provide some kind of interactive help that helps them navigate their way out of the mess or confusion they are in.

Anyways, as an inveterate tinkerer, this gets top marks from me just for existing, and for being open source. (The code is all on github.) Check it out.









twm’s blog: Storing gnugettext translations as resources

$
0
0

I always wondered why the assemble tool in dxgettext appends the translation files directly to the executable rather than using the existing mechanism of resources. This is no longer necessary. I have updated the gnugettext code to optionally use RCDATA resources named after the files.

So you e.g. create a translations.rc file as

LOCALE_DE_DEFAULT RCDATA ..\locale\de\LC_MESSAGES\default.mo
LOCALE_DE_DELPHI RCDATA ..\locale\de\LC_MESSAGES\delphi2007.mo
LOCALE_DE_DZLIB RCDATA ..\locale\de\LC_MESSAGES\dzlib.mo
LOCALE_EN_DEFAULT RCDATA ..\locale\en\LC_MESSAGES\default.mo
LOCALE_EN_DELPHI RCDATA ..\locale\en\LC_MESSAGES\delphi2007.mo
LOCALE_EN_DZLIB RCDATA ..\locale\en\LC_MESSAGES\dzlib.mo

Compile it using a resource compiler e.g. brcc32 to translations.res and add it to the executable.

The new code in gnugettext will automatically find and use these resources, all you have to do is add the conditional define dx_SupportsResources.

// if the conditional dx_SupportsResources is defined the .mo files
// can also be added to the executable as Windows resources
// Be warned: This has not been thoroughly tested.
// Default is turned off.
{.$define dx_SupportsResources}

You can find the updated gnugettext.pas in the dxgettext subversion repository on sourceforge.

Disclaimer: I have only cursorily tested this code. Use it at your own risk!

while true do;: #3 “dorm, the Delphi ORM” bullettin

$
0
0
A veeery log time after the last dorm bullettin. But, as usual, I was been very busy on some projects (not only dorm) and the time goes by… However, dorm has been extended, polished and improved over the last few months. Has been used in a couple other projects in my compoany (www.bittime.it). So, here’s a small [...]
Viewing all 1725 articles
Browse latest View live