Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

(Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 02 Mar 2023 20:03 #25508

  • stefan.ungemach
  • stefan.ungemach's Avatar
  • Topic Author


  • Posts: 14
  • I still struggle with some VO code pieces which throw warnings in XSharp:

    1. What would be the correct way to test if 2 strings occupy the same space in memory other than with

    IF PTR(SELF:_cValue) == PTR(cResult)

    2. How passing a string value to FUNCTION OurCharUpperW (pString AS WORD PTR, dwLen AS DWORD) AS PTR PASCAL other than by

    OurCharUpperW(PTR(_CAST,cResult), dwLen)

    3. Does this still work in X# (and how avoiding the warning)?

    function MarkAsUnicode(cString ref STRING) AS VOID PASCAL
    LOCAL pHeader AS _VO_STRING_DME
    LOCAL pCollInfo AS _VO_CollectInfo
    LOCAL bFlag AS BYTE

    pHeader := PTR(_CAST, DWORD(_CAST, PTR(_CAST,cString)) - _sizeof(_VO_DME_HEADER))

    // Check to see if the UNICODE bit is set
    pCollInfo := @pHeader.flh.colInf
    bFlag := pCollInfo.bFlag
    bFlag := _OR(bFlag, WAGNER_UNICODE)
    pCollInfo.bFlag := bFlag
    RETURN

    Please Log in or Create an account to join the conversation.

    (Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 02 Mar 2023 20:30 #25511

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Stefan,

    You can't do any of those things in .Net. Strings are immutable, you cannot modify directly their contents (without creating new strings) and you cannot access their memory location (at least not for any useful operation). You will need to do things in a different way, which way depends on what string manipulation you are doing in each case.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    (Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 02 Mar 2023 21:16 #25513

    • stefan.ungemach
    • stefan.ungemach's Avatar
    • Topic Author


  • Posts: 14
  • Hi Chris,

    maybe I don't need all that stuff which mostly comes from our own UnicodeString class. In X# a string is a set of Unicode chars, in VO it was Ansi (right?). So if I want i.e. to upper a Unicode string I can just call upper( cString ), right? I also suppose that all the handling passing strings from and to a dbf Field (where only Ansi is stored) happens internally, right?

    Sorry, but my biggest challenge is actually to decide which of all the tricks we do (like having Unicode content of DBF fields passed from and to VO controls) can be replaced or even be dropped...

    Is there a paper pointing out the whole X# string system from the point of an old developer who stuck with DBF and VO for decades? ;)

    Please Log in or Create an account to join the conversation.

    (Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 03 Mar 2023 00:52 #25515

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Stefan,

    It's not really the X# system, it's the .Net string system, apart from the automatic ANSI<->Unicode conversions (in dbfs, when reading/writing from text files etc), which indeed happen automatically by the X# runtime. It's actually still possible to use 8bit strings, via the PSZ type, but I wouldn't go that way, just use regular unicode strings which are the standard in .Net. And yes, of course you can just use Upper() on the unicode strings.

    What information exactly are you looking for regarding strings? There's plenty info around about strings in general in .Net, and there have been also many discussions here, will have a look to find some.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    (Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 03 Mar 2023 05:09 #25518

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Hi Stefan,
    if you have unicode strings in a DBF, maybe you need some dirty tricks like reading the DBF values using byte arrays and then converting it to a string. I cannot immagine another solution (I'm regularly storing compressed and/or crypted strings into DBF files, therefore I had to check that out).
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    (Still) confused with WORD PTR, PTR/PSZ and strings - how to avoid XS9068? 03 Mar 2023 09:09 #25521

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Good point Wolfgang! Stefan, in X# we have introduced a new method in the DBServer class, FieldGetBytes(), which reads the given field into a BYTE[] array. There's also a same named function, for if you're doing procedural access to dbs.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1