Page 4 of 57 FirstFirst ... 234561454 ... LastLast
Results 31 to 40 of 565

Thread: Tests Copying, Pasting, API Cliipboard issues. and Rough notes on Advanced API stuff

  1. #31
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    https://www.excelfox.com/forum/showt...age4#post17896
    https://www.excelfox.com/forum/showt...age4#post17896
    From here on are intermediate experiments and considerations on VB strings in the win32 api

    This post just has temporary notes for me so will be of no interest to anyone, or might be later. It may be a first attempt by me at some conclusions, with references that may be reproduced later better or help me to navigate better in my later conclusions




    From here on are intermediate experiments and considerations/ conclusion attempts on VB strings in the win32 api

    Consideration of the two typical forms of most api functions ( the WUnicorn and the AASI )


    Consideration of the two typical forms of most api functions involving strings ( the MyAPIFunctionWUnicorn and the MyAPIFunctionAASI ) helps also to understand what’s going on with strings in the win32 api
    For the time being, the difference between the the WUnicorn and the AASI can be considered as related some how the "WUnicorn AASI discussions in posts such as https://www.excelfox.com/forum/showt...ll=1#post24946 and previous



    https://eileenslounge.com/viewtopic....324730#p324730
    Api knows nothing about VB(A) strings…. If we restrict ourselves to the time from win32 api, then to all intents and purposes the
    Last edited by DocAElstein; 02-22-2025 at 02:32 PM.

  2. #32
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    This is post https://www.excelfox.com/forum/showt...age3#post17887
    Some further notes related to this post
    https://eileenslounge.com/viewtopic.php?f=30&t=41784
    https://eileenslounge.com/viewtopic....324039#p324039



    Some StrTrim experiments and musings
    Considering here some Jolly Trimmy, Jimmy Riddling, (Piddling about) with the win32 API Function StrTrim: - pseudo like it should do
    StrTrim("abad", "a") - > "bad"

    Let's see if we can learn any API stuff from experimenting with it. We will try it out in 4 forms:
    _ "straight" AASI, - the StrTrimA, string parameters as string type
    _ "Half way" (HWH) AASI. - the StrTrimA, string parameters as long (pointers)
    _ "Full" WUnicorn - the StrTrimW, string parameters as long (pointers)
    _ "Half way" (HWHWU) WUnicorn - - the StrTrimW, string parameters as string Type

    For each of the 4 sets of experiments , we
    _ first apply an idea suggested here as an win32 API function doping nothing, - the idea being to go through a lot of characters trimming nothing off, pseudo like
    StrTrim(Chucky(x), "") - > should be Chucky(x) , where Chucky(x) could be looped for x 0 – 255 or 0-65535 in the VBA functions Chr(x) or ChrW(x) , or alternatively in place of Chucky(x) we could just go through some list of characters, for example those in a code page list.
    Just to make that clear, let's say the character of interest is A, either taken from a list, or got from Chr(65) or ChrW(65)
    StrTrim(Chr(65), "") - > should be Chr(65)
    StrTrim("A", "") - > should be "A"
    We then compare the character going in with the character coming out.

    Our returned value (The ByVal/ByRef issue)
    Important to note, the pseudo coding above is pseudo coding, just to give the general idea.
    If you are familiar with VBA functions generally then you may typically experience the function returning something such as the result you want. A typical characteristic of win32 API functions in VBA is that the return from the function itself is most often something like a Boolean ( 0 or 1 ) to give some general indication of something, such as if the function "worked" or did something.( In this case a 1 would be returned if something was trimmed off, and a 0 otherwise).
    Any result we want comes typically from something similar to the classic Use of ByRef instead of function return value of a VBA function . (The fact that we use ByVal rather than the ByRef that we might initially have guessed is the major issue that sparked of these entire series of VBA win32 API musings. For here and now we just accept that ByVal is necessary)
    In short – the trimmed, ( or in this first experiment the untrimmed ) result is returned in the same variable we use to supply the input string, in our codings Ay in
    StrTrim(Ay, "")

    Spreadsheet for results
    We will exclusively use the spreadsheet for results, since some initial investigations suggests that the spreadsheet reproduces a very large number of different characters, so we can most likely assume that no extra complications are raised as a result of pasting out into a spreadsheet. Similarly we will assume that VBA variables hold accurately all characters so that a simple comparison of a variables holding the inputted and outputted character will gives us an accurate indication of if the character has changed. We can then list results thus:

    A True A 1

    a True a 1
    ā False a 1

    https://i.postimg.cc/Bt9cqfc6/Str-Tr...ng-results.jpg
    https://i.postimg.cc/0QsYSvdF/A-True-A.jpg
    (, where I am also including a number for the length of the output, 1 in this case. **The significance of that will be apparent later )

    _ secondly we do the same thing but with StrTrim arranged to do something, pseudo like
    StrTrim(Chucky(x) & "a" & Chucky(x) & "a" , "") - > should be "a" & Chucky(x) & "a"
    , to make that a bit more clear, let's say Chucky(x) is Chr(98) . ( or ChrW(98) ) , which is b , then
    StrTrim(Chr(98) & "a" & Chr(98) & "a" , Chr(98)) - > should be "a" & Chr(98) & "a"
    StrTrim(Chr(98) & "a" & Chr(98) & "a" , Chr(98)) - > should be "a" & "b" & "a"
    StrTrim(Chr(98) & "a" & Chr(98) & "a" , Chr(98)) - > should be "aba"
    StrTrim("baba" , "b") - > should be "aba"
    Correspondingly if the function does as it is intended, then our results will be
    baba Wahr aba
    https://i.postimg.cc/Vk1Vz9nj/baba-True-aba.jpg
    The True result will be based on the last 3 characters on the left being the same as the (first**) 3 characters on the right. I also include in some of these results again the length of the character set on the right. You can see for the first time in this next screen shot something screwy, as 4s are showing where we should see 3s. More to that again later
    https://i.postimg.cc/Wzwm71wx/Len-4-...d-of-Len-3.jpg

    A large file with a lot of results is here, I will add it for completeness and future reference.
    AASIWUnicorn.xlsm
    It is very crowded with coding and results, so below I will just
    _ give sample coding in the next post
    and
    _ talk though a small selection and make some general observations in the over next post .
    Attached Files Attached Files
    Last edited by DocAElstein; 02-22-2025 at 01:25 AM.

  3. #33
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Typical codings discussed in the previous post
    Here are just two sample codings from the workbook.
    The first coding uses the straight AASI version of the StrTrimA( , ) , and tries trimming nothing from as single character, or rather it loops through the entire ChW(x) list of characters , x = 0 - 65535 , attempting to trim nothing from it. The results it presents in column K https://i.postimg.cc/m2GW2cCN/Str-Tr...n-column-K.jpg
    Coding is in file the worksheets object code module, StrTrimRedundantSSD2
    Code:
    Option Explicit
    ' https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strtrima
    Private Declare Function StrTrim Lib "shlwapi.dll" Alias "StrTrimA" (ByVal psz As String, ByVal pszTrimChars As String) As Long '  '  Straight AASI          -   we'll be passing vb string to api
    Private Declare Function StrTrimTrickAW Lib "shlwapi.dll" Alias "StrTrimA" (ByVal psz As Long, ByVal pszTrimChars As Long) As Long '  Trick _ Half way house -  we'll be passing the StrPtr to API
    ' https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strtrimw
    Private Declare Function StrTrimTrickW Lib "shlwapi.dll" Alias "StrTrimW" (ByVal psz As Long, ByVal pszTrimChars As Long) As Long '   Full Unicorn's Bollox  -  we'll be passing the StrPtr to API
    Private Declare Function StrTrimTrickWUA Lib "shlwapi.dll" Alias "StrTrimW" (ByVal psz As String, ByVal pszTrimChars As String) As Long '   we'll be passing vb string to api
    '  https://eileenslounge.com/viewtopic.php?p=324039#p324039
    Private Sub JimmyRiddleAChrW() '  Straight AASI   ChrW
    Rem 0
    Dim Ay As String, Bea As String, Boo As Boolean, Cwt As Long, BooToo As Boolean
        For Cwt = 0 To 65535 '      All  ChW(x)  list of characters , x = 0 -  65535
         Let Ay = ChrW(Cwt): Let Bea = Ay  '  Bea  will be used later to comparte with what  Ay  becomes after used
        Rem 1
        Debug.Print "  " & Cwt & " " & ChrW(Cwt) & " ";  ' Some immediate Window output - genrally less useful in such experiments as the VB Editor and Immediate window do not do  WUnicode  so that adds another confusion. I ust the Excel Spreadsheet instead for viewable output --###
        Rem 2 ' call an AASI ' API function that does nothing to a character
         Let Boo = StrTrim(Ay, "") '                     ' The typical returned value from a function does not give a typical direct result. In this case it tells us if anything was trimmed.  We do not need this result
        Debug.Print Ay = Bea;                            ' Some immediate Window output
         Let BooToo = Ay = Bea                           ' The original variable  Ay  now has possibly overwritten in it  a new value, or not. Investigating this is  one of the purposes of this coding 
         Let Range("K" & Cwt + 3 & "") = " " & Bea & " " & BooToo & " " & Ay  ' I use the Excel Spreadsheet for output as it appears to have no issues with reproducing accurately many thousands of different characters. -------------------------------------------------------------###
        Next Cwt
    End Sub
    (The Immediate window results are of limited use in such experiments as the VB Editor and Immediate window do not do WUnicode so that adds another confusion. In further experiments we will mostly ignore the Immediate window or any other typical VB Editor debugging tools )
    https://i.postimg.cc/m2GW2cCN/Str-Tr...n-column-K.jpg




    The second coding example is the corresponding straight AASI approach with the attempt to get the StrTrim to actually do a trim
    I give it 4 characters, for example
    baba or caca
    , trimming correspondingly for those two examples with
    b or c
    , using arbitrarily the character a as a filler. So in those example the results would be expected of
    aba or aca
    Coding is in worksheets object code module StrTrimDoingSSD2
    Code:
    Option Explicit
    ' https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strtrima
    Private Declare Function StrTrim Lib "shlwapi.dll" Alias "StrTrimA" (ByVal psz As String, ByVal pszTrimChars As String) As Long '  '  Straight AASI          -   we'll be passing vb string to api
    Private Declare Function StrTrim Lib "shlwapi.dll" Alias "StrTrimA" (ByVal psz As String, ByVal pszTrimChars As String) As Long '  '  Straight AASI          -   we'll be passing vb string to api
    Private Declare Function StrTrimTrickAW Lib "shlwapi.dll" Alias "StrTrimA" (ByVal psz As Long, ByVal pszTrimChars As Long) As Long '  Trick _ Half way house -  we'll be passing the StrPtr to API
    ' https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strtrimw
    Private Declare Function StrTrimTrickW Lib "shlwapi.dll" Alias "StrTrimW" (ByVal psz As Long, ByVal pszTrimChars As Long) As Long '   Full Unicorn's Bollox  -  we'll be passing the StrPtr to API
    Private Declare Function StrTrimTrickWUA Lib "shlwapi.dll" Alias "StrTrimW" (ByVal psz As String, ByVal pszTrimChars As String) As Long '   we'll be passing vb string to api
     '  https://eileenslounge.com/viewtopic.php?p=324039#p324039
    Private Sub JimmyRiddleAChrW() '  Straight AASI   ChrW
    Rem 0
    Dim Ay As String, Bea As String, Boo As Boolean, Cwt As Long, BooToo As Boolean
        For Cwt = 0 To 65535
         Let Ay = ChrW(Cwt) & "a" & ChrW(Cwt) & "a": Let Bea = Ay    '  Bea  will be used later to comparte with what  Ay  becomes after used.  Ay  will itself possibly change on  "it's journey through"  the  StrTrim  function
        Rem 1
        Rem 2 ' call an AASI ' API function that does, or is intended to do, something to a string
         Let Boo = StrTrim(Ay, ChrW(Cwt)) '                           ' The typical returned value from a function does not give a typical direct result. In this case it tells us if anything was trimmed.  We do not need this result, although we will check it sometimes to see if it matches the apparant results
         Let BooToo = Right(Bea, 3) = Left(Ay, 3)                     ' If the function has done as intended, which is to trim of the  ChrW(Cwt)   then we expect the three right most characters on the original 4 character string to look like the returned results, which are overwritten into the original variable,  Ay  , (but there is a subtlty as we may expect an invisible  Chr(0)  on the end of the output, so we only compare to the first 3
         Let Range("K" & Cwt + 3 & "") = " " & Bea & " " & BooToo & " " & Ay '     & "       " & Len(Ay) & "   " & Boo ' ' I use the Excel Spreadsheet for output as it appears to have no issues with reproducing accurately many thousands of different characters.
        Next Cwt
    End Sub
    Private Sub JimmyRiddleAChr() '  Straight AASI  Chr
    https://i.postimg.cc/SKJmDYf9/First-...-something.jpg
    Last edited by DocAElstein; 02-21-2025 at 01:48 AM.

  4. #34
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Some initial observations and conclusions
    Some of these conclusions and observations may change as time goes on and I try many different computers, but provisionally, as notes to possibly come back to and update

    The character lists used in my experiments
    The VBA ChrW( ) function seems to give a consistent list across different computers
    The VBA Chr( ) and Excel CHAR( ) give identical results on any computer. (So from now on observations for the Chr( ) also apply to the CHAR( ) )
    The Chr( ) as expected is always the same characters across the 0-127 (ASCII) range. Above 127 the characters got from Chr( ) can vary on different computers. They do not seem to match the characters from the published tables based on the code page I obtain from chcp in PowerShell . They wouldn’t. … interrogating the code page from a (DOS) command such as chcp gives you the MS-DOS code page, not the windows code page .... You need to look at the GetACP API call The match with the characters from the relevant windows code page and Chr(x) is then the same ( https://www.excelfox.com/forum/showt...ll=1#post24947 )

    Observations for the StrTrim doing nothing to a character, (or maybe not actually doing anything to a character – subtle different…. Maybe….)
    Some conventions for these observation musings:
    "OK"
    If something is "OK", it means the character fed in via the variable, Ay , seems to be the same as that coming back in that variable. So this means results like
    Ê Wahr Ê ( Wahr on my mostly German computers is True in English )
    "Wonky"
    "Wonky" means I may not always get the OK results, but that at this stage I do not have enough results to be more precise.
    "Don't work"
    Something like "don't work" / not work, or similar means I mostly get a mismatch with what comes out compared to what goes in, but once again, at this stage I can't be more precise


    It may be easier to "work backwards"…

    The full WUnicorn
    The full WUnicorn appears to return the character it gets across the full 0 - 65535 decimal (Hex FFFF ) code point range

    The half way house WUnicorn
    The half way house WUnicorn is OK up to 127. From 128 to 255 it can be a bit wonky. Above 255 you may only occasionally find the odd Wahr ( True ) match to in and out

    The half way house ASII
    This appears to give the same "perfect" results as for the full WUnicorn for the case of StrTrim doing nothing to a character, (or maybe not actually doing anything to a character)

    The straight ASII
    Based on the first occurrence I saw of this, with the StrTrimA I was expecting this to not work above 255. At first glance this appeared to be the case. However as a result of looking more carefully, and also trying out a lot of computers I was able to see some anomalies , above 255 and also below 256

    _ For the Chr( ) characters the straight ASSI works (True result) across the 0-255 range

    _ For the ChrW( ) the story is interesting. These anomalies are such that not only do we see it working sometimes above 255 but also occasionally not working below 256
    Over the ASCII decimal code point range, 0 to 127 it mostly works, (True result)
    Going up to 160 it is mostly False
    From 160 to 255 they can all be True on a computer, or I have seen it approximately 50 50
    Above 255 to approximately 400 you can get just a few correct on one computer or about a third on another
    Here is an example for a computer with windows code page 1250
    https://i.postimg.cc/0jFgS1ZG/Straig...D2-CP-1252.jpg
    Last edited by DocAElstein; 02-22-2025 at 01:43 AM.

  5. #35
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    nnmn dn
    Last edited by DocAElstein; 02-22-2025 at 01:44 AM.

  6. #36
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    sbjsb
    Last edited by DocAElstein; 02-22-2025 at 01:44 AM.

  7. #37
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    y,cc
    Last edited by DocAElstein; 12-14-2024 at 03:52 PM.
    A Folk, A Forum, A Fuhrer …. Heil Schicklgruber

  8. #38
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    y,cc
    A Folk, A Forum, A Fuhrer …. Heil Schicklgruber

  9. #39
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    <
    Last edited by DocAElstein; 02-22-2025 at 01:44 AM.

  10. #40
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    <
    A Folk, A Forum, A Fuhrer …. Heil Schicklgruber

Similar Threads

  1. Some Date Notes and Tests
    By DocAElstein in forum Test Area
    Replies: 5
    Last Post: 03-26-2025, 02:56 AM
  2. Replies: 116
    Last Post: 02-23-2025, 12:13 AM
  3. Replies: 21
    Last Post: 12-15-2024, 07:13 PM
  4. Replies: 42
    Last Post: 05-29-2023, 01:19 PM
  5. Replies: 11
    Last Post: 10-13-2013, 10:53 PM

Posting Permissions

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