Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 34

Thread: How to sort files with custom function?

  1. #1

    How to sort files with custom function?

    Hello. I know there is some function CustomSort that enables to sort with a callback function, but how can I sort this?

    I have images named like bf15.png, bf35.png etc... bs00.png, bs30.png, etc.. mcf30.png, mcf45.png, mcf60.png etc. mhf15.png, mhf30.png etc. shf25.png, shf40.png etc. sls00.png, vbf25.png ... vhs00, png. vhs175.png, vvt120.png - all are various screenshot of the same object from various angles and I need to generate new files so that the images are sorted so that the cam focus is from top (seeing head) to bottom - (seeing feet). So the prefix means the height and the number means horizontal axis. In my program I have already defined the order in ENUM_prefixes_order and this order from top to bottom can be seen also in CONST_ViewPrefix. The file list is saved in ListFile TStringList. How should I implement this?



    Code:
    unit sort_the_files;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, file_fnc;
    
    const CONST_ViewPrefix: Array[0..8] of String = (
     'vvt', // very very top
     'vh',  // very high
     'sh',  // slightly high
     'mc',  // middle central view
     'sl',  // slightly low
     'vl',  // very low
     'b',   // botom
     'vb',  // very bottom
     'vvb'  // very very bottom
     );
     type ENUM_prefixes_order = (vvt, vh, sh, mc, sl, vl, b, vb, vvb);
     type TPrefixBase = Array[0..7] of Byte; // lengths of CONST_ViewPrefix
    
    type
      TForm1 = class(TForm)
        Button_Run: TButton;
      published
      procedure CreateForm(Sender: TObject);
      procedure read_file(path: string);
      procedure buttonClick(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
      ListFile: TStringList;
      PrefixBaseArray: TPrefixBase;
    
    implementation
    
    {$R *.dfm}
    
      function getPrefix(s: string; var sNum: String): string;
        var b: Byte;
            got_prefix: Boolean;
        begin
          Result := '';
          sNum:= '';
          got_prefix := false;
          for b:=1 to length(s) do
            if (ord(s[b])>47)
             AND (ord(s[b])<58) then
              begin
                if got_prefix = false then
                  got_prefix := true;
                sNum := sNum+s[b];
              end
             else
              begin
              if not got_prefix then
                Result:=Result+s[b]
              else
                exit;  
              end;
        end;
    
    
    procedure TForm1.buttonClick(Sender: TObject);
    var i: Integer;
        prefix: string;
        sNum: String;
        number: Word;
    begin
      for i:=0 to ListFile.count-1 do
      begin
      prefix := getPrefix(ListFile[i], sNum);
      number := strToInt(sNum);
      showmessage(ListFile[i]+' '+prefix+' '+sNum);
    
      end;
    
    end;
    procedure TForm1.read_file(path: string);
    begin
    if ListFile=Nil then
      ListFile := TStringList.Create;
      CreateFileNamesList(path, ListFile);
    end;
    procedure TForm1.CreateForm(Sender: TObject);
    var u: byte;
    begin
      for u:=0 to length(PrefixBaseArray)-1 do
      PrefixBaseArray[u]:= length(CONST_ViewPrefix[u]);
      read_file('U:\3D model MAN\fotky');
    end;
    end.

  2. #2
    Quote Originally Posted by chlopik View Post
    Hello. I know there is some function CustomSort that enables to sort with a callback function, but how can I sort this?
    Je kunt een 'gewicht' toekennen aan de prefix.

    Dat is eigenlijk vrij eenvoudig te realiseren door gebruik te maken van de index in de Prefix string tabel.

    Je sorteert (of eigenlijk vergelijkt) dan eerst het 'gewicht' van de prefix van de vergelijking-strings met elkaar. Als deze gewichten met elkaar overeenstemmen dan pas vergelijk je de nummers uit beide strings.

    I have images named like bf15.png, bf35.png etc... bs00.png, bs30.png, etc.. mcf30.png, mcf45.png, mcf60.png etc. mhf15.png, mhf30.png etc. shf25.png, shf40.png etc. sls00.png, vbf25.png ... vhs00, png. vhs175.png, vvt120.png
    U bent zich bewust van het feit dat deze gegeven bestandsnamen niet allemaal (of niet volledig) voorkomen in uw prefix-tabel ?

    Er wordt dus in het midden gelaten (phun intended) wat te doen met deze namen die weliswaar beginnen met een prefix uit de tabel maar nog een of meerdere letters bevatten voordat het nummer in de bestandsnaam begint.

    De code die ik laat zien laat dat dan ook maar in het midden en plaats deze willekeurig onderaan in de lijst zoals deze langs de TSortcompare funktie zijn langsgekomen.

    and I need to generate new files so that the images are sorted so that the cam focus is from top (seeing head) to bottom -
    Je code bevat geen enkele indicatie dat er nieuwe bestanden dienen te worden gemaakt.

    Je hebt het over het sorteren van een lijst..... hoe kan dit helpen bij het genereren van een nieuwe bestand ?

    Dat is mij in ieder geval niet duidelijk, maar misschien dat ik ergens iets over het hoofd zie ?

    The file list is saved in ListFile TStringList. How should I implement this?
    Ik heb geen idee hoe je de nieuwe bestandsnamen wilt formuleren of hoe je denkt dat dit wordt weergegeven.

    Echter voor de goede orde plaats ik maar een sorteer implementatie. Dat laat in ieder geval zien hoe dat werkt (of kan werken).

    Code is van origine gemaakt met Free Pascal, dus als er problem zijn dan hoor ik het wel.

    Commentaar is in Engels (dat dan weer wel )



    Code:
    program sorting;
    
    {$mode delphi}{$H+}
    
    uses
      classes, sysutils, strutils;
    
    const
      // Note that your prefixes do not match (all) the provided filenames
      // so am assuming these prefixes are used to determine filenames
      // that /starts/ with these strings
      Prefixes: array[0..8] of string = (
       'vvt', // very very top
       'vh',  // very high
       'sh',  // slightly high
       'mc',  // middle central view
       'sl',  // slightly low
       'vl',  // very low
       'b',   // botom
       'vb',  // very bottom
       'vvb'  // very very bottom
     );
    
    // Very sloppy/wrong function to retrieve the prefix and numeric part of a filename
    // Only here to show you that you can use actual characters instead of.
    // using those non-explanatory ord values.
    function SplitIntoPrefixAndNumber(s: string; var Prefix: string; var Number: integer): boolean;
    var
      ch    : char;
      numsy : string = '';
    begin
      result := false;
      prefix := '';
      number := 0;
    
      for ch in s do
      begin
        case ch of
          '0'..'9' : numsy := numsy + ch;
          '.'      : break;
          'a'..'z' : prefix := prefix + ch;
          else       break;
        end;
      end;
    
      number := StrToInt(numsy);
    end;
    
    // Get the 'weight' of a prefix based on the index of prefixes.
    // Note that it is easier to use AnsiIndexStr but that requires
    // to match all the filename letters
    function getPrefixWeight(Prefix: string): integer;
    var
      idx: integer;
    begin
      // easy solution using AnsiIndexStr:
      // result := AnsiIndexStr(Prefix, PrefixValues);
    
      // Using manual startswith instead:
      // correction for weight in case non-matching
      result := High(Prefixes) + 1;
      for idx := low(Prefixes) to High(Prefixes) do
      begin
        if AnsiStartsStr(Prefixes[idx], Prefix) then exit(idx);
      end;
    end;
    // The actual sorting implementation
    // Callback type as per:
    // FPC   : https://www.freepascal.org/docs-html...rtcompare.html
    // Delphi: https://docwiki.embarcadero.com/Libr...istSortCompare
    // TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;
    function StringListSortCompare(sl: TStringList; idx1, idx2: Integer): Integer;
    var
      s1   , s2   : string;  // current lines to compare
      pfs1 , pfs2 : string;  // current prefix string parts
      pfw1 , pfw2 : integer; // current prefix 'weights'
      num1 , num2 : integer; // current number parts
    begin
      result := 0;
    
      // get filename strings that needs to be compared
      s1 := sl[idx1];
      s2 := sl[idx2];
    
      // get prefixes and numbers from corresponding filenames
      SplitIntoPrefixAndNumber(s1, pfs1, num1);
      SplitIntoPrefixAndNumber(s2, pfs2, num2);
    
      // get 'value' (weight) of a prefix
      // note that GetPrefixWeight already accounts for
      // non matching prefixes such as mhxnn.png
      // if there is need fo a different behaviour then code needs to be adjusted accordingly.
      pfw1 := GetPrefixWeight(pfs1);
      pfw2 := GetPrefixWeight(pfs2);
    
      // in case you wish to 'witness' the actual sorting
      // writeln('s1:',s1:10,' pfs1:', pfs1:3, ' num1:', num1:3, ' pfw1:', pfw1);
      // writeln('s2:',s2:10,' pfs2:', pfs2:3, ' num2:', num2:3, ' pfw2:', pfw2);
    
      // prefix weights differ so exit sorting based on the weight
      if pfw1 <> pfw2 then exit(pfw1 - pfw2);
    
      // prefix weights are same so need to sort on number as well
      exit(num1 - num2);
    
      // in case wanting to add even more sorting rules then compare the two
      // item(parts) and when they match, move on to the next sort comparison
      // e.g. only exit the sort routine when the item-parts differ.
      // You can do that indefinitely...
    
      // You can sort 'backwards' with a change of the sign of the result.
    end;
    
    procedure fill(strings: TStrings; sa: array of string);
    var
      s: string;
    begin
      for s in sa do strings.Add(s);
    end;
    
    procedure show(strings: TStrings);
    var s:string;
    begin
      for s in strings do writeln(s);
    end;
    
    procedure shuffle(strings: TStrings);
    var
      ridx, idx: integer;
    begin
      randomize;
      for idx :=  0 to strings.count-1 do
      begin
        ridx := random(strings.count-idx);
        strings.Exchange(idx, idx + ridx);
      end;
    end;
    
    
    const
      ExampleFilenames: array[0..15] of string =
      (
       'bf15.png', 'bf35.png',
       'bs00.png', 'bs30.png',
       'mcf30.png', 'mcf45.png', 'mcf60.png',
       'mhf15.png', 'mhf30.png',
       'shf25.png', 'shf40.png',
       'sls00.png', 'vbf25.png',.
       'vhs00.png', 'vhs175.png', 'vvt120.png'
       );
    
    var
      SomeList: TStringList;
    
    begin
      SomeList := TStringList.Create;
    
      fill(SomeList, ExampleFilenames);
    
      writeln('unsorted');
      show(SomeList);
      writeln;
    
      writeln('shuffled');
      shuffle(SomeList);
      show(SomeList);
      writeln;
    
      writeln('sorted (default)');
      SomeList.Sort;
      show(SomeList);
      writeln;
    
      // Using customsort as per:.
      // FPC   : https://www.freepascal.org/docs-html...ustomsort.html
      // Delphi: https://docwiki.embarcadero.com/Libr...ist.CustomSort
      SomeList.CustomSort(StringListSortCompare);
    
      writeln('custom sorted');
      show(SomeList);
      writeln;
    
      SomeList.Free;
    end.
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  3. #3
    Thank you for your efford. And yes, I forgot to mention the rest of the problem.

    complete prefix is like vhf or vhr or vhs - which can be ignored, it just describes the relation between angle and the view: front, rear or side view. Not important for sorting. For sorting is important prefix base like vh and the number. We could think or compare it with sorting of files in Windows Explorer where we have type and name columns. And I usually want to sort them by type, but the exact name is the second criteria to sort. Here the base prefix is the type.

    I don't need to create the files now, I look for sorting funtion only. The rest of the job is easy for me.

    Update to the get prefix function:
    Code:
      function getPrefix(s: string; var sNum: String): string;
        var b: Byte;
            got_prefix: Boolean;
        begin
          Result := '';
          sNum:= '';
          got_prefix := false;
          for b:=1 to length(s) do
            begin
            case s[b] of
              'a'..'z':
                begin
                if not got_prefix then
                  Result:=Result+s[b];
                end;
              '0'..'9':
                begin
                sNum := sNum+s[b];
                if got_prefix = false then
                  got_prefix := true;
                end;
            end;
            end;
      end;
    Last edited by chlopik; 11-Jul-22 at 09:57.

  4. #4
    Ok, in that case the sorting as implemented in my code works as you intended. well, sort of.

    The problem with using AnsiStartsStr is that multiple matches can occur (currently in my code, it picks the first one) because it depends on the lengths of the prefix whether or not a filename actually matches a prefix. So, you would need to sort the prefixes table based on length (longest first in the list then down to shortest) and then do the AnsiStartStr comparison. If you need to keep the weight of the original (unsorted) table then you would need to cross-reference the index (as that is used as weight). (*)

    Besides that the obvious exception that does not match anything are filenames starting with mhf as there is no provision in the prefix table for that.

    (*) The current implementation works for the provided prefixes table, but as soon as you start adding other prefixes to that table then you need to take the mentioned paragraph into account. Unless you are 100% sure that no prefix contains (part of) another prefix.
    Last edited by flabber; 11-Jul-22 at 10:11. Reason: clarification
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  5. #5
    I'm sorry that today I am slow in reading and my reactions/responses will take longer.
    getPrefixWeight - Not sure but I think that instead of AnsiStartsStr another funtion should be used; one, which can return the index. Because the index should be 1 as the substring must be found on the begin of the haystack.
    function AnsiStartsStr ( const Needle, Haystack : string ) : Boolean;
    That is because looking for 'vh' in 'vvh30.png' could incorrectly detect base prefix as 'vh'. Not tested.

  6. #6
    base prefix 'mh' stands for "medium high"

    Code:
    const CONST_ViewPrefix: Array[0..9] of String = (
     'vvt', // very very top
     'vh',  // very high
     'sh',  // slightly high
     'mc',  // middle central view
     'mh',  // medium high
     'sl',  // slightly low
     'vl',  // very low
     'b',   // botom
     'vb',  // very bottom
     'vvb'  // very very bottom
     );
    Last edited by chlopik; 11-Jul-22 at 10:44.

  7. #7
    Quote Originally Posted by chlopik View Post
    I'm sorry that today I am slow in reading and my reactions/responses will take longer.
    No problem. I'm not in a hurry ... are you ?

    getPrefixWeight - Not sure but I think that instead of AnsiStartsStr another funtion should be used; one, which can return the index. Because the index should be 1 as the substring must be found on the begin of the haystack.
    function AnsiStartsStr ( const Needle, Haystack : string ) : Boolean;
    That is because looking for 'vh' in 'vvh30.png' could incorrectly detect base prefix as 'vh'. Not tested.
    Originally I used IndexStr but that does not work if you want to ignore the last characters in a filename.

    As you stated, the filename must begin with f.e. mc in the filename mcf030.png and therefor must match the first two characters. Ergo I used StartsWith inside a loop that returns the index when the StartsWith reports it as a match. Note that the AnsiStartsWith is being used the other way around as people are usually used to.

    But... the proof is in the pudding... this is the list it creates when using the customsort:
    Code:
    vvt120.png
    vhs00.png
    vhs175.png
    shf25.png
    shf40.png
    mcf30.png
    mcf45.png
    mcf60.png
    sls00.png
    bs00.png
    bf15.png
    bs30.png
    bf35.png
    vbf25.png
    mhf15.png
    mhf30.png
    Last edited by flabber; 11-Jul-22 at 10:34. Reason: pudding
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  8. #8
    No I am not in hurry, but I am tired today for some reason.

    I have renamed the const array to CONST_PrefixBase:

    Code:
    if AnsiStartsStr(CONST_PrefixBase[idx], Prefix) then
          exit(idx); // Error: [Error] sorting_fnc.pas(33): Missing operator or semicolon
    Now trying to solve the error.

    And AnsiStartsStr is the correct function. My wrong.

    What do you expect from exit(idx);? In D7 exit; allowed.
    Last edited by chlopik; 11-Jul-22 at 11:11.

  9. #9
    Quote Originally Posted by chlopik View Post
    No I am not in hurry, but I am tired today for some reason.
    I'll try to keep you awake then... otherwise there is always the next day

    Code:
    if AnsiStartsStr(CONST_PrefixBase[idx], Prefix) then
          exit(idx); // Error: [Error] sorting_fnc.pas(33): Missing operator or semicolon
    No idea why that would raise an error.


    What do you expect from exit(idx);? In D7 exit; allowed.
    exit without a value is exiting from a procedure.

    exit with a value will set the result to IDX and exits the function. Ergo this can only be used inside a function.

    On both accounts it is a quick exit from your current subroutine. Frowned upon by many coding purists but something you would use in practical use to keep your code clean (as much as possible).

    PS: ah ok, Delphi 7. That explains why you can't compile my posted code out of the box (I'll try and see what I can do). Hint: use Free Pascal
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  10. #10
    I am using my own function to get the prefix - and I god error there while reading the files. But I still have problems to generate my own message. I tried Raise Exception.Create('some sort of text...'); but did not generate the message. Because I need to see the string. Can you improve my code?

    Code:
      Try
    num := strToInt(sNum);
      Except
       ShowMessage('INCORRECT VALUE: '+sNum);
    end;

  11. #11
    With regards to the exit error you got. My bad. exit with a value was introduced in Delphi 2009 so Delphi 7 does not seem to have it.

    This is an attempt at a Delphi7 compatible version:
    Code:
    program sorting;
    
    {$mode delphi}{$H+}
    
    uses
      classes, sysutils, strutils;
    
    const
      // Known filename Prefix (letters) table. Their index is used as 'weight'
      Prefixes: array[0..9] of string = (
       'vvt', // very very top
       'vh',  // very high
       'sh',  // slightly high
       'mc',  // middle central view
       'mh',  // medium high
       'sl',  // slightly low
       'vl',  // very low
       'b',   // botom
       'vb',  // very bottom
       'vvb'  // very very bottom
     );
    
    // Still quick 'n' sloppy function
    function SplitIntoPrefixAndNumber(s: string; var Prefix: string; var Number: integer): boolean;
    var
      idx   : integer;
      ch    : char;
      numsy : string = '';
    begin
      result := false;
      prefix := '';
      number := 0;
    
      for idx := 1 to length(s) do
      begin
        ch := s[idx];
        case ch of
          '0'..'9' : numsy := numsy + ch;
          '.'      : break;
          'a'..'z' : prefix := prefix + ch;
          else       break;
        end;
      end;
    
      number := StrToInt(numsy);
    end;
    
    // Get the 'weight' of a prefix based on the index of prefixes.
    function getPrefixWeight(Prefix: string): integer;
    var
      idx: integer;
    begin
      // correction for weight in case non-matching
      result := High(Prefixes) + 1;
    
      // parse Prefixes array from top to bottom
      // and exits by returning the index value when the.
      // filename Prefix starts with the first letters.
      // from the current item in the prefixes table.
      for idx := low(Prefixes) to High(Prefixes) do
      begin
        if AnsiStartsStr(Prefixes[idx], Prefix) then
        begin
          result := idx;
          exit;
        end;
      end;
      // See setting the result in the first line of this
      // routine:
      // if no prefix match was found then return the highest
      // possible 'weight' to indicate this.
      // This 'weight' will then be automatically sorted to.
      // the bottom of the list.
    end;
    
    // The actual sorting implementation
    // Callback type as per:
    // FPC   : https://www.freepascal.org/docs-html/rtl/classes/tstringlistsortcompare.html
    // Delphi: https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TStringListSortCompare
    // TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;
    function StringListSortCompare(sl: TStringList; idx1, idx2: Integer): Integer;
    const
      SortDescending = false;   // set to true to sort in descending order
    var
      filename1 , filename2   : string;  // current filenames to compare
      prefix1   , prefix2     : string;  // current prefix string parts
      weight1   , weight2     : integer; // current prefix 'weights'
      number1   , number2     : integer; // current number parts
    begin
      result := 0;
    
      // get filename strings that needs to be compared
      filename1 := sl[idx1];
      filename2 := sl[idx2];
    
      // get prefixes and numbers from corresponding filenames
      SplitIntoPrefixAndNumber(filename1, prefix1, number1);
      SplitIntoPrefixAndNumber(filename2, prefix2, number2);
    
      // get 'value' (weight) of a prefix
      // note that GetPrefixWeight already accounts for non-matching
      // prefixes and they are placed at the bottom of the list
      // because they have the 'highest' weight.
      weight1 := GetPrefixWeight(prefix1);
      weight2 := GetPrefixWeight(prefix2);
    
      // in case you wish to 'witness' the actual sorting
    //  writeln('filename1:',filename1:10,' prefix1:', prefix1:3, ' number1:', number1:3, ' weigth1:', weight1);
    //  writeln('filename2:',filename2:10,' prefix2:', prefix2:3, ' number2:', number2:3, ' weight2:', weight2);
    
      // prefix weights differ so exit sorting based on the weight
      if weight1 <> weight2 then
      begin
        if SortDescending
          then result := weight2 - weight1
            else result := weight1 - weight2;
        exit;
      end;
    
      // prefix weights are same so need to sort on number as well
      if SortDescending.
        then result := number2 - number1
          else result := number1 - number2;
      exit;
    
      // in case wanting to add even more sorting rules then compare the two
      // item(parts) and when they match, move on to the next sort comparison
      // e.g. only exit the sort routine when the item-parts differ.
      // That can be done indefinitely...
    end;
    
    procedure fill(strings: TStrings; sa: array of string);
    var idx: integer;
    begin
      for idx := low(sa) to high(sa)
        do strings.Add(sa[idx]);
    end;
    
    procedure show(strings: TStrings);
    var idx: integer;
    begin
      for idx := 0 to strings.count-1
        do writeln(strings[idx]);
    end;
    
    procedure shuffle(strings: TStrings);
    var
      ridx, idx: integer;
    begin
      randomize;
      for idx :=  0 to strings.count-1 do
      begin
        ridx := random(strings.count-idx);
        strings.Exchange(idx, idx + ridx);
      end;
    end;
    
    
    const
      ExampleFilenames: array[0..15] of string =
      (
       'bf15.png', 'bf35.png',
       'bs00.png', 'bs30.png',
       'mcf30.png', 'mcf45.png', 'mcf60.png',
       'mhf15.png', 'mhf30.png',
       'shf25.png', 'shf40.png',
       'sls00.png', 'vbf25.png',.
       'vhs00.png', 'vhs175.png', 'vvt120.png'
       );
    
    var
      SomeList: TStringList;
    
    begin
      SomeList := TStringList.Create;
    
      fill(SomeList, ExampleFilenames);
    
      writeln('unsorted');
      show(SomeList);
      writeln;
    
      writeln('shuffled');
      shuffle(SomeList);
      show(SomeList);
      writeln;
    
      writeln('sorted (default)');
      SomeList.Sort;
      show(SomeList);
      writeln;
    
      // Using customsort as per:.
      // FPC   : https://www.freepascal.org/docs-html/rtl/classes/tstringlist.customsort.html
      // Delphi: https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TStringList.CustomSort
      SomeList.CustomSort(StringListSortCompare);
    
      writeln('custom sorted');
      show(SomeList);
      writeln;
    
      SomeList.Free;
    end.
    Mostly the same but some stuff rewritten to make it compatible with Delphi7 (hopefully). Added the missing prefix that you added (and I initially missed) and added a descending sort option so you can see how that is done.

    For me it outputs:
    Code:
    unsorted
    bf15.png
    bf35.png
    bs00.png
    bs30.png
    mcf30.png
    mcf45.png
    mcf60.png
    mhf15.png
    mhf30.png
    shf25.png
    shf40.png
    sls00.png
    vbf25.png
    vhs00.png
    vhs175.png
    vvt120.png
    
    shuffled
    mhf30.png
    mcf60.png
    mcf45.png
    bs30.png
    vbf25.png
    vhs00.png
    shf25.png
    bf15.png
    bf35.png
    vhs175.png
    mhf15.png
    shf40.png
    sls00.png
    vvt120.png
    bs00.png
    mcf30.png
    
    sorted (default)
    bf15.png
    bf35.png
    bs00.png
    bs30.png
    mcf30.png
    mcf45.png
    mcf60.png
    mhf15.png
    mhf30.png
    shf25.png
    shf40.png
    sls00.png
    vbf25.png
    vhs00.png
    vhs175.png
    vvt120.png
    
    custom sorted
    vvt120.png
    vhs00.png
    vhs175.png
    shf25.png
    shf40.png
    mcf30.png
    mcf45.png
    mcf60.png
    mhf15.png
    mhf30.png
    sls00.png
    bs00.png
    bf15.png
    bs30.png
    bf35.png
    vbf25.png
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  12. #12
    I would like to Try and Catch error for number := StrToInt(..)
    so that I see the input string passed to function. Please help, let it is perfect . Because I still don't know the invalid string which I am passing in.

  13. #13
    Darn board. I see your message about 5 minutes after I posted mine so I was not aware that you posted already (again).

    Does delphi 7 have something like this ? https://www.freepascal.org/docs-html...ystrtoint.html

    edit: if not then you could try the code here http://www.delphibasics.co.uk/RTL.asp?Name=StrToInt
    Last edited by flabber; 11-Jul-22 at 12:37. Reason: link
    Iedereen wist dat het onmogelijk was. Behalve dan die ene dwaas die dat niet helemaal goed had begrepen en het toch deed.

  14. #14
    I would like to Try and Catch error for number := StrToInt(..)
    so that I see the input string passed to function. Please help, let it is perfect . Because I still don't know the invalid string which I am passing in.

  15. #15
    Oh yeah.

    Code:
    if not TryStrToInt(sNum, num) then
        showmessage('sNum:"'+sNum+'"');
    So I will debug now my fnc.

Page 1 of 3 1 2 3 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •