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

TOPIC:

Size of Char[] array? 01 Mar 2023 20:26 #25469

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


  • Posts: 14
  • This code gives me a warning XS9021 in the red line:

    ...
    pResult := Char[]{dwResult}
    XSharp.ADS.ACE.AdsGetString(self:_hADT, cFieldName, pResult, @dwResult, ADS_NONE)
    ...

    PUBLIC STATIC METHOD AdsGetString(hTable As PTR, lFieldOrdinal As DWORD, pucBuf As CHAR[], pulLen Ref DWORD, usOption As WORD) As DWORD

    Problem is that the called method wants a DWORD as 4. parameter, and it can indeed fill a buffer which is larger than MAX_WORD. How can I prepare a large buffer other than the red line's code?

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

    Size of Char[] array? 01 Mar 2023 21:10 #25470

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Stefan,

    The constructor of the System.Array class expects an integer (elements of the array), that's why you get the warning. I guess it's very unlikely that the dwResult var will ever hold a number greater than MAX LONG INT :), so you can just convert it to INT: pResult := Char[]{ INT(dwResult) }
    XSharp Development Team
    chris(at)xsharp.eu

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

    Last edit: by Chris.

    Size of Char[] array? 01 Mar 2023 21:16 #25471

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


  • Posts: 14
  • Hi Chris, thanks, that did the trick.

    BTW: Apologies for so many stupid questions, but I've finally started to migrate our complex VO framework to XSharp - and that's 1.5 millions of code lines ;)

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

    Size of Char[] array? 01 Mar 2023 23:05 #25475

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Stefan,

    Please don't worry at all, there are no stupid questions :)
    Good luck with your migration, please don't hesitate to ask anything!
    XSharp Development Team
    chris(at)xsharp.eu

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

    Size of Char[] array? 02 Mar 2023 10:45 #25494

    • robert
    • robert's Avatar


  • Posts: 3599
  • Stefan
    At first, it may look strange that some of these functions accept a signed number. How can you ever create an array with a negative number of elements?
    The reason for this is that although the .Net system supports unsigned number, these were initially not part of what is called the Common Language Specification (CLS), so .Net languages did not have to support them to be "first class" .Net languages.

    essentialcsharp.com/common-language-specification

    Therefore, the constructors for many types only take signed integers.
    And methods like IndexOf() and properties like Length also return signed integers. They often use -1 as special value to indicate that for example IndexOf() did not find anything.
    The VO developers used 1 based indexes for characters in a string and elements in an array. They use 0 as special value and used unsigned integers for sizes and indices.

    Robert
    XSharp Development Team
    The Netherlands

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

    • Page:
    • 1