1. marco gaspar
  2. PowerBuilder
  3. Monday, 24 July 2023 12:18 PM UTC

Good morning! How should I declare a variable of type word?
Thanks!

Roland Smith Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 17:15 PM UTC
  2. PowerBuilder
  3. # 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?

 

 

Comment
  1. marco gaspar
  2. Monday, 24 July 2023 18:10 PM UTC
For example, I'm trying to utilize the XFS APIs for use in our ATMs. I don't know how to declare them.

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.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 14:19 PM UTC
  2. PowerBuilder
  3. # 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

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 13:24 PM UTC
  2. PowerBuilder
  3. # 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

 

Comment
There are no comments made yet.
marco gaspar Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 13:21 PM UTC
  2. PowerBuilder
  3. # 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!

Comment
  1. René Ullrich
  2. Monday, 24 July 2023 13:35 PM UTC
LP means "Long Pointer"

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.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 13:10 PM UTC
  2. PowerBuilder
  3. # 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

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 13:04 PM UTC
  2. PowerBuilder
  3. # 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.

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 24 July 2023 13:03 PM UTC
  2. PowerBuilder
  3. # 7

AFAIK the WORD data type is 2 Byte. So it should be INTEGER (or short: INT) or UNSINGNED INTEGER (short: UINT) in PowerBuilder.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.