Good morning! How should I declare a variable of type word?
Thanks!
- You are here:
- Home
- Q&A
- Q&A
- PowerBuilder
- Variable of type word!
- marco gaspar
- PowerBuilder
- Monday, 24 July 2023 12:18 PM UTC
- Monday, 24 July 2023 17:15 PM UTC
- PowerBuilder
- # 1
From the Microsoft data types page:
WORD - A 16-bit unsigned integer. The range is 0 through 65535 decimal.
Therefore WORD is unsignedinteger in PowerBuilder. USHORT is also an unsignedinteger.
What is the API function you are trying to define?
- Monday, 24 July 2023 14:19 PM UTC
- PowerBuilder
- # 2
Here is a link to a very handy list of WinAPI data types that I refer to frequently:
https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
A PB String is an array of Unicode characters, and array arguments get passed as the memory address of (a pointer) to the start of the string/array... so LPSTR (Long Pointer to a STRing) is simply a String in PB, as others in this thread have stated.
A DWORD is a 32-bit unsigned integer, or a UnsignedLong/ULong in PB. For PB to pass the address of a DWORD, specify the REF or READONLY keyword ahead of the argument in the external function declaration. Both will work, but REF is required if the DLL will be changing the value of the PB argument value. If the DLL will be assigning a value to a PB String or populating a PB numeric array, the string/array should be populated or initialized in PB before calling the DLL function with the maximum required size. For example, if a string value of up to 100 characters will be returned, initialize the string in PB via the Space(100) function call.
As for structure members, all members that are pointers should be declared as a PB Longptr so that it will work in either 32-bit or 64-bit (PB 12.6 and later).
Populating a structure with a pointer to a DWORD or other non-string, non-array variable can be difficult since PB does not support pointers.
Best regards, John
- Monday, 24 July 2023 13:24 PM UTC
- PowerBuilder
- # 3
What would be length of the word that you would like to store in a variable?
Generally in Powerbuilder we declare that as
String ls_name
And if you want to store the value in a database (in a field of a table), then that field to be declared as
name varchar(50) -> it might differ depending on the DBMS
HTH
Happiness Always
BKR Sivaprakash
- Monday, 24 July 2023 13:21 PM UTC
- PowerBuilder
- # 4
Good morning John!
In the cooperative where I work, we have ATMs. These same boxes use dlls to communicate with the peripherals.
Ex: function Integer WinStartLeAssyncronoCmgLDIP(integer timeout) library "p32ldip.dll" alias for "WinStartAssyncronoCmgLDIP;Ansi".
This will soon be over and we will be using: Extensions for Financial Services (XFS) interface Specification.
These extensions use some structures such as:
Output Param LPWFSCEUCAPS lpCaps;
typedef struct _wfs_ceu_caps
{
WORD wClass;
BOOL bCompound;
BOOL bCompareMagneticStripe;
BOOL bMagneticStripeRead;
BOOL bMagneticStripeWrite;
BOOL bChipIO;
WORD wChipProtocol;
LPSTR lpszExtra;
BOOL bPowerSaveControl;
WORD fwCharSupport;
WORD fwType;
BOOL bAntiFraudModule;
LPDWORD lpdwSynchronizableCommands;
} WFSCEUCAPS, *LPWFSCEUCAPS;
typedef struct _wfs_ceu_form
{
LPSTR lpszFormName;
LPSTR lpszFields;
WORD fwCharSupport;
WORD wLanguageID;
} WFSCEUFORM, *LPWFSCEUFORM;
Some variables confuse me, for example: LPSTR, LPDWORD.
So I need to know, which is the reference in PB of these variables for me to create the variables.
Thanks!
- René Ullrich
- Monday, 24 July 2023 13:35 PM UTC
LPSTR is a pointer to a string. In PowerBuilder this is the STRING data type.
LPDWORD should be a pointer to a double word. Maybe you can usePB ULONG or LONG data type but I'm not sure.
-
Helpful Loading... Helpful 0
- Monday, 24 July 2023 13:10 PM UTC
- PowerBuilder
- # 5
Hi, Marco -
Can you please provide some context? What are you trying to do?
I'm guessing that "Word!" is an enumeration, so it is an example of a particular enumerated type. You can declare a variable of the enumerated type (such as SaveAsType, for example), then that variable will accepted any of the valid enumerations of that enumerated type:
SaveAsType lsat // A "save as type" enumeration variable
lsat = Xlsx! // An example of an enumerated value for that type.
If you can supply us with additional information, we can probably respond with a more exact, detailed answer.
Best regards, John
- Monday, 24 July 2023 13:04 PM UTC
- PowerBuilder
- # 6
Hi.
Are you trying to do an api call? If that's the case, word should be an unsignedinteger in Powerbuilder.
Declaring external functions - - PowerScript Reference (appeon.com) under Fixed-point values.
Andreas.
- Monday, 24 July 2023 13:03 PM UTC
- PowerBuilder
- # 7
AFAIK the WORD data type is 2 Byte. So it should be INTEGER (or short: INT) or UNSINGNED INTEGER (short: UINT) in PowerBuilder.
- Page :
- 1
However, you are not allowed to reply to this question.
When I used it like this:
FUNCTION Integer XFS_Abre_Leitora_Cartao() LIBRARY "XFS_LITE.DLL" alias for "XFS_Abre_Leitora_Cartao;Ansi".
But these APIs do not use dll
Grateful.