Jump to content

JeanCremers

Members
  • Content Count

    37
  • Joined

  • Last visited

Posts posted by JeanCremers


  1. I didn't see your question about the numeric values.

    The é = 101 and the  =  116.

    The corresponding chars in my diacritics table are 233 and 228 though.

    i tried changing them with

    if (newName[i] == 101 || newName[i] == 116)
    		{
    		newName[i] = (newName[i] == 101 ? 'e' : 'a');
      OutputDebugStringW(newName.c_str());
    		changed = true;
    		}

    But i get:

    Debug Output: Duo Canope´e play Sta¨ndchen by Franz Schubert on a 1968 D. Friederich Guitar & Violoncello.webm Process diacritics.exe (2792)

     


  2. the forum does not display the code correctly, i have to use spaces in the bracket like newName[ i ]

    Forgot to say, other files with diacritics are catched, just this particular one is not. Duo Canopée play Ständchen by Franz Schubert on a 1968 D. Friederich Guitar & Violoncello.webm

     

    If i put this in the findfirst/next loop R.Name is still the original but ch becomes plain 'e'

     if (R.Name.Pos("Duo Canop"))
    {
    WideChar ch = R.Name[10];
    }
     


  3. You are right, it was a my fault, i did not test it properly, the file is catched with plain RTL functions, only that file is never having detected to have diacritics, never gets added to the listview.

     

        const int DIACRITIC_COUNT = 29; 
        static const WideChar diacritics[DIACRITIC_COUNT] = {
            L'á', L'à', L'â', L'ä', L'ã', L'å',
            L'é', L'è', L'ê', L'ë',
            L'í', L'ì', L'î', L'ï',
            L'ó', L'ò', L'ô', L'ö', L'õ',
            L'ú', L'ù', L'û', L'ü',
            L'ý', L'ÿ',
            L'ñ',
            L'ç',
            L'Ñ'
        };
        static const WideChar replacements[DIACRITIC_COUNT] = {
            L'a', L'a', L'a', L'a', L'a', L'a',
            L'e', L'e', L'e', L'e',
            L'i', L'i', L'i', L'i',
            L'o', L'o', L'o', L'o', L'o',
            L'u', L'u', L'u', L'u',
            L'y', L'y',
            L'n',
            L'c',
            L'N'
        };

    if (FindFirst(dir + "\\*.*", faAnyFile, R) == 0) do if(!(R.Attr & faDirectory))
      {
      String newName = R.Name;
      bool changed = false;
      for(int i = 1; i <= newName.Length(); i++)
        for (int j = 0; j < DIACRITIC_COUNT; j++)
          {
          if(newName == diacritics[j])
            {
            newName = replacements[j];
            changed = true;
            }
          }
        if(changed)
          {
          TListItem* item = ListView1->Items->Add();
          item->Caption = R.Name;
          item->SubItems->Add(newName);
          }
      } while (FindNext(R) == 0);
    FindClose(R);
     


  4. 3 minutes ago, Remy Lebeau said:

    The RTL's Find(First|Next)() functions use the Win32 Find(First|Next)FileW() APIs internally, and have done so since 2009.

     

    Hi Remy, the files i mention really did not show up using the RTL ones. Off course i would prefer that. And using the debugger i got strange names like Canope´e play Sta¨ndchen.


  5. The debugger displays the name like

    Debug Output: Duo Canope´e play Sta¨ndchen by Franz Schubert on a 1968 D. Friederich Guitar & Violoncello.webm

    How do i catch these so i can rename them?

    Edit, had to use the windows FindFirstFileW to get it right.

     

    Ps, I have used c++builder 12 in the past, this one is real shitty. FindFile/Next not working properly. Properties not surviving oncreate(), i had a crash that trashed my source completely, mwooooooh. I'm not gonna port my main app to this version.


  6. i have this code, but it does not catch the filename 'Duo Canopée play Ständchen by Franz Schubert on a 1968 D. Friederich Guitar & Violoncello.webm', why not???

     

    #define DIACRITIC_COUNT 10
        static const WideChar diacritics[DIACRITIC_COUNT] = {
            L'á', L'à', L'â', L'ä', L'ã', L'å',
            L'é', L'è', L'ê', L'ë',
        };

        static const WideChar replacements[DIACRITIC_COUNT] = {
            L'a', L'a', L'a', L'a', L'a', L'a',
            L'e', L'e', L'e', L'e',
        };


    if(FindFirst(dir + L"\\*.*", faAnyFile, sr) == 0)
        {
            do {
                if(!(sr.Attr & faDirectory))
                {
                    String newName = sr.Name;
                    bool changed = false;
                    for(int i = 1; i <= newName.Length(); i++)
                      {
                      WideChar ch = newName;
                       for (int j = 0; j < DIACRITIC_COUNT; j++)
                          {
                            if(ch == diacritics[j])
                            {
                            newName = replacements[j];
                            changed = true;
                            }
                          }
                      }
                    if(changed) {
                        TListItem* item = ListView1->Items->Add();
                        item->Caption = sr.Name;
                        item->SubItems->Add(newName);
                    }
                }
            } while(FindNext(sr) == 0);
            FindClose(sr);
        }

     


  7. Thanks Remy.

    I'm getting EOSError 'System Error. Code 1411, Class does not exist.'

    This is c++builder 6 🙂

     

    Edit, i also tried 

    
    void __fastcall TAstroClockMainForm::ApplicationEvents1Message(tagMSG &Msg,
          bool &Handled)
    {
    if (Msg.message == WM_APP)
      Application->MessageBox("", "", MB_OK);
    
    }
    
    


    and

     

    
    HWND hwnd = FindWindow("TAstroclockMainForm", NULL);
    if (hwnd)
      SendMessage(hwnd, WM_APP, 0, 0);
    
    

  8. Ok, so one prog does for instance 

    
    HWND hwnd = FindWindow(NULL, "myprog");
    if (hwnd)
      SendMessage(hwnd, WM_USER, 0, 0);
    
    

     

    And what exactly should the other prog do? I have this, but it's not working.

    
    in form constructor Application->HookMainWindow(&AppHook);
    
     
    
    bool __fastcall TMainForm::AppHook(TMessage &Message)
    {
    if (Message.Msg == WM_USER)
      {
    
      Application->MessageBox("", "", MB_OK);
      return true;
      }
    return false;
    }
    

     

    But i'm not getting any msg there.

     

    Thanks.


  9. 1 hour ago, Vandrovnik said:

    If you use type "currency" instead of "double", it would work too and you can avoid most of the conversions between numerical and string types. Currency can keep 4 decimal places (even the 0.1 🙂 ).

    Can't do, i need type double, its for a script language and it has no currency type, but it has double. And this works for my needs.


  10. 8 minutes ago, David Heffernan said:

    Then you are going to need to work out what your problem really is. Because it hasn't been stated here. If you want to work with numbers that have a finite number of decimal digits, then use a decimal type. It is precisely why such things exist.

    I'm ok with my current solution, it does what i need it to do.


  11. 1 hour ago, David Heffernan said:

    Neither. Spawn of satan, should never have been published.

     

    In your case do all the behind the scenes work using integers and then divide by 10 just when you need the actual value. Or use a decimal type like currency.

    🙂

     

    Thanks. I tried the multiply/divide trick, but not with 10 but with 100000 and ran into similar problems. Converting to a string and back to a float at least seems to work against the cumulative issue.


  12. So i thought 0.1 was representable in floating point, obviously not.

    How do i use IsZero() or SameValue in a situation like this.

     

    updownbuttonclick(TObject *Sender, TUDBtnType Button)

    {

    value += (Button == btNext ? 0.1 : -0.1);

    }

     

    What i'm doing now is convert value to a string and then back to fp, this eliminates the cumulative rounding error. How to tackle this with one of those math functions?

     

    Thanks.


  13. Hello,

    I found a strange complier/linker bug. I'm still using bcb 6 but i thought i'd check with c++builder 10.4 and lo and behold, there's the same bug.

    Look at the image, it says it all, the result should be zero but it's not.

    You can see the result in the caption, it's always this number 2.77etc E-17.

    I've also seen it happen with 10 - 0.1 giving 9.911111 or something.

    Man i feel bad, i made my life's work with this.

     

    Please try this yourself.

    2022-11-23_10-35.png

    • Haha 1
×