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?
Size of Char[] array?
-
- Posts: 71
- Joined: Thu Jul 15, 2021 10:46 am
- Location: Germany
Size of Char[] array?
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) }
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
![Smile :)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_smile.gif)
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 71
- Joined: Thu Jul 15, 2021 10:46 am
- Location: Germany
Size of Char[] array?
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![Wink ;)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
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
![Wink ;)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
Size of Char[] array?
Hi Stefan,
Please don't worry at all, there are no stupid questions![Smile :)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_smile.gif)
Good luck with your migration, please don't hesitate to ask anything!
Please don't worry at all, there are no stupid questions
![Smile :)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_smile.gif)
Good luck with your migration, please don't hesitate to ask anything!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Size of Char[] array?
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.
https://essentialcsharp.com/common-lang ... cification
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
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.
https://essentialcsharp.com/common-lang ... cification
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
robert@xsharp.eu
The Netherlands
robert@xsharp.eu