Jump to content


  • Content count

  • Joined

  • Last visited

About Dennis07

  • Rank

  • Birthday 04/15/1994

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Berlin, Germany
  • Interests
    Programming. Nothing else.


  • Company name
    The Smart Company AS
  • Sector
    Information technology
  • Position
    Software developer

Smart Mobile Studio

  • Edition

Recent Profile Visitors

256 profile views
  1. Dennis07

    Save and load SQLite Database to local storage

    I cannot tell you how the DB stuff in SMS works in detail. I can only tell you how the stream classes work. If your problem is DB-related, I personally cannot help you. I will however redirect this to the team, they will surely tell you what to do! Sorry for this.
  2. Dennis07

    Save and load SQLite Database to local storage

    It's even easier than that. At least for the streaming part, you can use ONE stream instance and cast it to TMemoryStream or TStringStream. TStringStream is a child class of TMemoryStream. Just access its String this way: var MyStream: TMemoryStream; //... (MyStream as TStringStream).DataString //... It's really simple!
  3. Dennis07

    Syntax Error: Unknown name

    No, because the SMS compiler is 100% independent from the SCL stuff. However, the {$I...} directive is automatically added to the code if you create a form app through a wizard. And doing something like this reliably is something we cannot do, because the compiler/IDE/editor/... never knows if this file was meant to be part of this form class.
  4. Dennis07


    Because the initialization section is called only after the variables get initialized.
  5. Dennis07


    Initialization with 0 / '' / 0.0 / nil is implicite in Smart Pascal Why so complicated? function PostInc(var i: integer); begin Result := i; inc(i); end;
  6. Dennis07

    TPersistent idea

    We already have an alternative, it's called TInstance. However, we do not include it in our RTL because of performance issues. unit System.Persistent; interface { TInstance class for the SMS RTL ------------------------------------------------------------------------------ This is a (heavily) enhanced version of Delphi's TPersistent class. It does not only offer an assignment functionality, but also other stuff explained below: - Instances[Index] allows the access of a TInstance object at runtime. The amount of instances can be retrieved with the InstanceCount property. The index of the current instance in the global Instances[Index] property can be retrieved using the InstanceIndexIn function, which internally calls the global IndexOfInstance class function. - Default stores an instance with all properties set to the default values. The current instance can be reset to this default property using the Reset method. - AssignTo/AssignFrom both call the global Assign class procedure which can be overridden by the user. It is there to assign the values of one instance to another. - CompareTo calls the global Compare class function which can be overriden by the user as well. It is meant to offer a simple comparison between two TInstance instances. The result -1 means that the Second parameter comes before the First parameter and +1 means that the First parameter comes before the Second parameter. Result = 0 means they are equal. - Alternatively, the AssignProc property can be defined with an instance of TInstanceAssignProc allowing to change the assignment behaviour at runtime. The same is offered for comparisons by the CompareProc property for instances of TCompareProc. Both properties are public and are only called if the Assign/Compare methods have not been overridden. They can be manually called inside the overridden procedures of course, however. - EqualTo calls the global Equal class procedure returning whether the global Compare class procedure for the two object parameters returns 0. - As DWS does not seem to support class constructors/destructors, this class "emulates" them by introducing public OnClassCreate/OnClassDestroy events of the new TInstanceClass event. When the first instance of a class is being created, it will run the OnClassCreate method, the corresponding with OnClassDestroy. This is not really the "same" as a class constructor in Delphi, but it's the closest possible. - ParentOf/ChildOf return true if the current class is a parent/child of the other class. The full class heritage back to TInstance is recognized. Both methods call the global class method Heritage which returns either the heritage gap between the Parent and Child parameters or -1 if there is no. - IterateInstances executes an instance of TInstanceIterateProc for each instance of the current TInstance class. } type TInstance = class; TInstanceClass = class of TInstance; TInstanceCompareProc = function (First,Second: TInstance): Integer; TInstanceAssignProc = procedure (Source,Target: TInstance); TInstanceIterateProc = procedure (Instance: TInstance; Index: Integer; var Interrupted: Boolean); TInstanceClassEvent = procedure (Sender: TClass); TInstance = class abstract private class var FOnClassCreate: TInstanceClassEvent; class var FOnClassDestroy: TInstanceClassEvent; class var FInstances: array of TInstance; class var FCompareProc: TInstanceCompareProc; class var FAssignProc: TInstanceAssignProc; class function GetInstances(Index: Integer): TInstance; class function GetInstanceCount: Integer; protected class function GetDefault: TInstance; virtual; public class property OnClassCreate: TInstanceClassEvent read FOnClassCreate write FOnClassCreate; class property OnClassDestroy: TInstanceClassEvent read FOnClassDestroy write FOnClassDestroy; class property Instances[Index: Integer]: TInstance read GetInstances; class property InstanceCount: Integer read GetInstanceCount; class property Default: TInstance read GetDefault; class property CompareProc: TInstanceCompareProc read FCompareProc write FCompareProc; class property AssignProc: TInstanceAssignProc read FAssignProc write FAssignProc; class procedure Assign(Source, Target: TInstance); virtual; class function Compare(First, Second: TInstance): Integer; virtual; class function Equal(First, Second: TInstance): Boolean; class function Heritage(Parent, Child: TInstanceClass): Integer; class function ParentOf(InstanceClass: TInstanceClass): Boolean; class function ChildOf(InstanceClass: TInstanceClass): Boolean; class function IndexOfInstance(Instance: TInstance): Integer; class procedure IterateInstances(Proc: TInstanceIterateProc); constructor Create; destructor Destroy; override; function InstanceIndexIn(InstanceClass: TInstanceClass): Integer; procedure AssignFrom(Source: TInstance); procedure AssignTo(Target: TInstance); function CompareTo(Other: TInstance): Integer; function EqualTo(Other: TInstance): Boolean; procedure Reset; end; implementation class function TInstance.GetInstances(Index: Integer): TInstance; begin Result := FInstances[Index]; end; class function TInstance.GetInstanceCount: Integer; begin Result := FInstances.Length; end; class function TInstance.GetDefault: TInstance; begin Result := Self.Create; end; class procedure TInstance.Assign(Source, Target: TInstance); begin AssignProc(Source, Target); end; class function TInstance.Compare(First, Second: TInstance): Integer; begin Result := CompareProc(First, Second); end; class function TInstance.Equal(First, Second: TInstance): Boolean; begin Result := Compare(First, Second) = 0; end; class function TInstance.Heritage(Parent, Child: TInstanceClass): Integer; begin Result := 0; while Child <> TClass do begin if Child = Parent then begin Exit; end; Child := TInstanceClass(Child.ClassParent); Inc(Result); end; Result := -1; end; class function TInstance.ParentOf(InstanceClass: TInstanceClass): Boolean; begin Result := Heritage(Self, InstanceClass) <> -1; end; class function TInstance.ChildOf(InstanceClass: TInstanceClass): Boolean; begin Result := Heritage(InstanceClass, Self) <> -1; end; class function TInstance.IndexOfInstance(Instance: TInstance): Integer; begin Result := FInstances.IndexOf(Instance); end; class procedure TInstance.IterateInstances(Proc: TInstanceIterateProc); var Index: Integer; Interrupted: Boolean; begin Index := 0; while (Index < InstanceCount) and (not Interrupted) do begin Proc(FInstances[Index], Index, Interrupted); end; end; constructor TInstance.Create; begin inherited Create; if (InstanceCount = 0) and Assigned(OnClassCreate) then begin OnClassCreate(ClassType); end; FInstances.Add(Self); end; destructor TInstance.Destroy; begin FInstances.Remove(Self); if (InstanceCount = 0) and Assigned(OnClassCreate) then begin OnClassDestroy(ClassType); end; inherited Destroy; end; function TInstance.InstanceIndexIn(InstanceClass: TInstanceClass): Integer; begin Result := InstanceClass.IndexOfInstance(Self); end; procedure TInstance.AssignFrom(Source: TInstance); begin Source.AssignTo(Self); end; procedure TInstance.AssignTo(Target: TInstance); begin Assign(Self,Target); end; function TInstance.CompareTo(Other: TInstance): Integer; begin Result := Compare(Self, Other); end; function TInstance.EqualTo(Other: TInstance): Boolean; begin Result := Equal(Self, Other); end; procedure TInstance.Reset; begin AssignFrom(Default); end; end.
  7. Dennis07

    Property description

    Seen it (randomly as I needed to post an own issue few hours ago). The description, as I wrote, is not relevant for us, and (likely) won't be attended by SMS. The property overloading would however be cool to have also in SMS. I'll pay attention to this. Thanks!
  8. Dennis07

    Property description

    We are planning to add this to SPc in a while. However, we agreed on not adding this as a language feature but rather as meta information stored in so-called "Smart Doc" files. This will basically store a structural representation of the Smart Pascal source code with the ability to add custom descriptions and other kind of info to everything in the source code (not just properties or published elements). A prototype I've designed so far (we're however not sure whether this is gonna be the final format) is shown in the attached file. Again, this is not final and we're not sure how and what the actual result of our construction will be in the end, but this is as far as we've gotten at the moment.
  9. Dennis07

    Property overloading

    Something like that is also possible in Smart Pascal (just like Delphi): TEntityMode = (em1, em2); TEntitySetting = class abstract protected property IsNull: Boolean; end; TEntitySetting1 = class(TEntitySetting) private FValue: String; method SetValue(const AValue: String); begin FValue := AValue; IsNull := FValue.Length = 0; end; published property Value: String read FValue write SetValue; end; TEntitySetting2 = class(TEntitySetting) private FValue: Integer; method SetValue(const AValue: Integer); begin FValue := AValue; IsNull := FValue = 0; end; published property Value: Integer read FValue write SetValue; end; TEntity = class private FSetting1: TEntitySetting; FSetting2: TEntitySetting; FMode: TEntityMode = em1; FSetting: TEntitySetting; method SetMode(const AValue: TEntityMode); begin FMode := AValue; case FMode of em1: FSetting := FSetting1; em2: FSetting := FSetting2; end; end; public constructor Create; begin inherited Create; FSetting1 := new TEntitySetting1; FSetting2 := new TEntitySetting2; end; published property Mode: TEntityMode read FMode write SetMode; property Setting: TEntitySetting read FSetting; end;
  10. Dennis07

    Property overloading

    The thing is, Delphi practically permitts property overloading (at least for indexed properties, but... Oficially, according to Emb, there is no evidence that this is a supported feature. Even Emb itself does not do it this way in their own libraries. It requires at least one index parameter. The parameter types must differ from property to property. Doing it will crash the debugger, at least this used to be the case in earlier D versions. Can't tell you atm of this is still the case. Smart Mobile Studio / DWS does not allow this at the moment, and even in Delphi you should avoid this where possible. As an alternative to this, you can use one of these ways in Smart Pascal: Use different names for the properties. Use "Variant" as parameter type. Use an object as parameter type and declare two different constructors for it. One with a String and one with an Integer as parameter. Use public overloaded getter/setter methods instead of a property. They do support overloading. Use a unified String paremeter and a second parameter with an enum determining how the first parameter should be treated.
  11. Dennis07


    It had been promised in 2014 by Eric, so yea, we should I'd say. Maybe in SmartCL.System?
  12. Dennis07

    Smart 2.9.9 [alpha] is here!

    The final steps are currently being done, the update will be pushed as soon as this has been finished. A matter of days as far as I can estimate.
  13. Dennis07

    New forum software version

    Okay, uploading profile banners with up to 500KB should work now for standard users as well. Let me know if there still exist problems.
  14. Dear Smart community! we are proud to announce that we finished updating the software of our forums, as you might have noticed. If you encounter bugs, please let us know about them so that we can take care of them as soon as possible. Stuff like clearing notifications, editing profile settings, setting profile pics should work now without problems. Wishing you all the best!
  15. Dennis07

    problem, maybe...

    Thank you, this might be a useful addition for the future!