Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. maybe my sample can help you to start... implementation {$R *.dfm} uses System.Rtti, Unit2; procedure TForm1.Button1Click(Sender: TObject); var LCtx : TRttiContext; LType : TRttiType; LProp : TRttiProperty; LPropParent: string; begin LCtx := TRttiContext.Create; for LType in LCtx.GetTypes do begin if (LType.TypeKind = tkClass) { TRttiInstanceType } and { } (LType.IsInstance) and { } (LType.AsInstance.MetaclassType.InheritsFrom(TMyClassXXXX { myClass } ) or { } LType.AsInstance.MetaclassType.InheritsFrom(TForm { myClass } )) then begin Memo1.Lines.Add(slinebreak + { } LType.Name + ', ' + { } LType.AsInstance.MetaclassType.UnitName + ', ' + { } LType.AsInstance.MetaclassType.UnitScope); // for LProp in LType.GetProperties do if (LProp.Name = 'Width' { myPropetyName } ) then begin LPropParent := 'Parent=nil'; // if (LProp.Parent <> nil) then LPropParent := 'Parent=' + LProp.Parent.ToString; // Memo1.Lines.Add('..... property: ' + LProp.Name + ', ' + LPropParent); end; end; end; end;
  2. programmerdelphi2k

    corrupt primary key?

    you can specify "CHARSET and COLLATE": in you "connection string" for all usage (CHARSET/COLLATE ) or in "select, insert, update" on fields (CHARSET/COLLATE) on in your index creation or in "order by" (CHARSET/COLLATE) ex.: select myfield COLLATE <<your collation>> from table where myfieldx COLLATE <<your collation>> = 'ABC' order by myfieldY COLLATE <<your collation>> etc... you see?
  3. programmerdelphi2k

    How to detect if a Dialog is open/running?

    if using "if YourForm.SHOWING then = "opened" in your screen" not?
  4. programmerdelphi2k

    Animating rectangle position in code using fmx

    implementation {$R *.fmx} var LImComingOrGoing: boolean = true; procedure TForm1.FormCreate(Sender: TObject); begin FloatAnimation1.StartValue := Rectangle2.Position.Y; FloatAnimation1.StopValue := (Rectangle2.Position.Y - 100); // FloatAnimation1.Trigger := 'IsMouseOver=True'; FloatAnimation1.TriggerInverse := 'IsMouseOver=False'; FloatAnimation1.PropertyName := 'Position.Y'; // FloatAnimation1.Duration := 0.5; FloatAnimation1.AutoReverse := false; // FloatAnimation1.StartValue := Rectangle2.Position.Y; FloatAnimation1.StopValue := (FloatAnimation1.StartValue - 100); end; procedure TForm1.FloatAnimation1Finish(Sender: TObject); begin FloatAnimation1.Stop; // if LImComingOrGoing then begin FloatAnimation1.StartValue := Rectangle2.Position.Y; FloatAnimation1.StopValue := (FloatAnimation1.StartValue - 100); end else begin FloatAnimation1.StartValue := Rectangle2.Position.Y; FloatAnimation1.StopValue := (FloatAnimation1.StartValue + 100); end; // LImComingOrGoing := not LImComingOrGoing; end;
  5. this code it's not mine! I just say "where" put it... on "try-finally" as I said on first post, "CODE CONFUSED"!!!
  6. programmerdelphi2k

    Why AV happen here

    @stacker_liew if any "AV" is been raised, when you: trying to access an object that was never created in memory; trying to access an object that no longer exists in memory;
  7. programmerdelphi2k

    corrupt primary key?

    using any specific Charset or Collate on field?
  8. confused code! try create your "Excel" just one time... out any procedure! for example, before any use in your unit. Then, when all end, just free it!
  9. try this: download last version from https://www.o2c.de/en/download/o2c-download.html install it for register all Ocx on "MSRegistry! in IDE "Import Component - Type Library -> new package installation! RAD 11.2 Alexandria test!
  10. does this plugin require "Internet Explorer" by default or any browser?
  11. programmerdelphi2k

    Delete substring from a string

    try this sample: function MyFindAndReplace2(const AStr: string; const ASubStr: string; const ADelimiter: Char): string; var LArr : TArray<string>; LNewArr: TArray<string>; begin result := AStr.Replace(' ', '', [rfReplaceAll]); // removing blank-spaces... // if (result.Trim = '') or (ASubStr.Trim = '') or (ADelimiter = #32) then exit(''); // LArr := result.Split([ADelimiter], TStringSplitOptions.ExcludeEmpty); // for var i: integer := 0 to high(LArr) do // only if not found! if (LArr[i] <> ASubStr) then LNewArr := LNewArr + [LArr[i]]; // result := ''.join(ADelimiter, LNewArr); end; procedure TForm1.Button3Click(Sender: TObject); var LText : string; LSubText: string; begin LText := ' 100,1000, 10, 1001, 101,102,100,,,,103,104, 100,100'; // ' '; // ' ,,'; // ' 1, ,'; LSubText := '100'; // Memo1.Text := LText; // Memo1.Lines.Add('Result=[' + MyFindAndReplace2(LText, LSubText, ',') + ']'); end;
  12. programmerdelphi2k

    Set Print Font Size...

    Isn't there any "proportionality" in the printer options (before printing...), between screen and printer? Does this also happen if I set the font to all of MS Windows (on config from MS) and want to print... say the current screen on my monitor from any other software? What if I print from MSWord with a huge font on the screen, and send this print-screen or document to the printer? What happens in this case on your system? Is it comparable to your report about your RAD Studio IDE, or is the IDE case an exception (Bug)? sorry, I have a 4K to test it!
  13. programmerdelphi2k

    Delete substring from a string

    you try this: '100,' or ',100' or ',100,' --> comma as determinant on expression if "comma" dont exists, dont worry! nothing will be changed! [rfReplaceAll] or [ ] for just 1 LText will have always a valid value, same that empty!
  14. Well, then the "Array DML technique" would allow multiple "DML commands" with parameters to be automated! so if using: "insert ....; "delete ...." we could produce a "multiple executions to 2 commands" ... with each execution of the array!
  15. I dont know if help you, but do you try use "Arrays DML"? https://docwiki.embarcadero.com/RADStudio/Sydney/en/Array_DML_(FireDAC)#:~:text=The Array DML execution technique,for each row in arrays.
  16. programmerdelphi2k

    I get value=none

    "Ai Caramba!" It's good to see when someone takes their own poison... 😋
  17. programmerdelphi2k

    order by string same integer

    on code you can try this: procedure TForm1.Button1Click(Sender: TObject); var LArr : TArray<string>; LArrMask: TArray<integer>; LText : string; LCounter: integer; LZeros : integer; begin Memo1.Lines.Clear; Memo2.Lines.Clear; // // NOT normalized LArr := ['1', '1.1', '1.1.1', '1.1.1.1', '1.1.1.2', '1.1.1.3', '1.1.1.4', '1.1.1.5', '1.1.1.6', '1.1.1.7', '1.1.2', { } '1.1.2.1', '1.1.2.2', '1.1.3', '1.1.3.1', '1.1.4', '1.1.4.1', '1.1.4.2', '1.1.5', '1.1.5.1', '1.1.6', '1.1.6.1', { } '1.1.6.2 ', '1.2', '1.2.1', '1.2.1.1', '1.2.1.10', '1.2.1.11', '1.2.1.2', '1.2.1.3', '1.2.1.4', '1.2.1.5', { } '1.2.1.6', '1.2.1.7', '1.2.1.8', '1.2.1.9']; // TArray.Sort<string>(LArr); Memo1.Lines.AddStrings(LArr); // LArrMask := [1, 4, 2, 3]; // your mask! -> try LArrMask := [0, 2, 0, 3]; // for var i: integer := 0 to high(LArr) do begin LText := ''; LCounter := 0; // for var A in LArr[i].Trim.Split(['.']) do // Trim or "replace all space-chars" like in '1.1.6.2 ' begin LZeros := (LArrMask[LCounter] - A.Length); // better without "Abs()" // if (LZeros > 0) then LText := LText + '.' + ''.Create('0', LZeros) + A else LText := LText + '.' + A; // LCounter := LCounter + 1; end; // LArr[i] := LText.Remove(0, 1); end; // TArray.Sort<string>(LArr); Memo2.Lines.AddStrings(LArr); end; LArrMask := [0, 2, 0, 3]; NOTE: you can find the "mask values" scanning all items array, and with "Split()" function + Length = deteminated what the values for your mask! x = max value between 1 and length(text)
  18. programmerdelphi2k

    order by string same integer

    hi @mofareh Pay attention: your data in your table it's stored like : 1.1, 1.2 ..... 1.2.1, 1.2.2.... let's say that you used this mask: n.n.nnn ( n = digits ) then, you'll need update your table values to: 1.1.001, 1.1.002 .... 1.2.001, 1.2.002 .... for this, you'll need just "edit the values already stored", and your index will be uptadted! NOTE IMPORTANT: if "this values is used in some relationship between tables, then, you'll need another approach, or some maneuvers to change the size of the fields involved, for example! Now, if you don't use these fields to create relationships between tables, then it will be easier to update: for example: Create a new field in the table with the desired size to accommodate the new values now, read each record and get the old value, make the necessary changes to have the new format, and then save this new value in the new field; if all goes well, then now you can decide whether or not you want to delete the old column (field) from your table, and use the new field by default!
  19. programmerdelphi2k

    order by string same integer

    for reading: https://www.sqlshack.com/top-five-considerations-for-sql-server-index-design/
  20. programmerdelphi2k

    order by string same integer

    You need add "Uses clause" before; // What's your RAD Studio?
  21. programmerdelphi2k

    order by string same integer

    ok, but see as used on index: space =char(32) "0" = char(48) "1" = char(49) "9" =char(57) "." = char(58)
  22. programmerdelphi2k

    order by string same integer

    if using "strings" (in your case), I think that you need fill left-side with "0..." when save your data, or replacing when necessary on code! // you can "before store it on table... using Before Insert/Post event or a stored-procedure", apply some mask? procedure TForm1.Button1Click(Sender: TObject); var LArr: TArray<string>; begin LArr := ['1.2.10', '1.1.10', '1.2.9', '1.2.10', '1.1.9', '1.2.1']; TArray.Sort<string>(LArr); Memo1.Lines.AddStrings(LArr); // // normalized Memo1.Lines.Add('---- Normalized ----'); LArr := ['1.2.10', '1.1.10', '1.2.09', '1.2.10', '1.1.09', '1.2.01']; TArray.Sort<string>(LArr); Memo1.Lines.AddStrings(LArr); end;
  23. programmerdelphi2k

    Pos

    procedure TForm1.Button1Click(Sender: TObject); var LText: string; begin LText := 'old value'; // ... while if not LText.Contains('new value') then LText := LText + ',' + 'new value'; // ... end while ShowMessage( LText.Remove(0,1) ); // remove first comma end; or just
  24. programmerdelphi2k

    MSBuild - set library paths without touching IDE options

    you can look the "detailed log" created by MSBuild using " /distributedFileLogger" = create a msbuild1.log file on project folder!
×