5. Global versus Local External Function declaration. If the function is declared globally it can be called from anywhere in your application. If you declare the function as a Local External Function it can only be called from that window where it's declared. Local Function use less resources then globals but the difference is very minimal.
Error Messages and what they mean:
1. Error: Error opening DLL library <filename> for external function at line <line_number> in the <event name> event of object <object_name> of <window_name>.
Possible causes:
> DLL is 16 bit and thus incompatible.
> DLL is not in a searchable directory.
> DLL connects to another DLL that cannot be found.
> DLL has the same name as another already loaded into memory.
> DLL is corrupted or in an incompatible format.
2. Error: Error calling external function <function_name> at line <line_number> in the <event name> event of object <object_name> of <window_name>.
This is probably the result of an incorrectly spelt function name. Be sure to verify that the function name matches what is in the DLL exactly, including the case of the letters.
3. Error: Specified argument type differs from required argument type at runtime in DLL function <function_name>. (Invalid stack pointer on return from function call) at line <line_number> in <event_name> event of object <object_name> of <window_name>.
This error usually indicates the datatypes do not match what the DLL function is expecting.
4. PB050: Caused an Invalid Page Fault in module PBSHR050.DLL @ 0137:1111163e
This error can occur either immediately upon calling the function or when the application closes. The module and memory address may vary but the reason for this is usually the same. If PB is receiving a string and memory isn't allocated in advance using the SPACE( ) that string will overflow into another memory area. To allocate 12 characters to the string "ls_filename" the following code would be used.
ls_filename = space(13) // You may want to give it an extra space just to be safe.
5. Receiving garbage from the DLL. i.e. Last name populated as: "*#^&Ryan"
This problem is most likely the result of the byte alignment being set incorrectly. PowerBuilder expects the byte alignment to be set to one and if you are using MSVC++ compiler the default setting is four. To set the byte alignment to one you would need to do the following prior to compiling to a dll.
- Select the desired target
- Right mouse click and select Settings
- Select the C/C++ tabpage
- Select Code Generation from the Category dropdown list
- Select desired byte alignment from the Struct Member Alignment dropdown list.
The DOS switch to set the byte alignment to one is: /zp1
A handy trick to find functions quickly:1. On Win95,Win98 or NT 4.0 click on the START button and select "Find", then "Files or Folders".
2. In the SLE entitled "Named" enter "c:\*.dll". If this is a Windows DLL that you'll be calling enter "c:\windows\*.dll".
3. Click on the "Advanced" tab and in the "Containing Text" SLE enter the exact function name you are looking for. For example: FindWindowA
4. There will usually be a lot of DLL's that contain the function you are looking for but try to use the main Windows DLL's whenever possible since they are already loaded into memory.
Related Faxlines:
47626 - External Functions Calls to the DLLs created using Visual C++
44596 - 16 Bit - Windows API Calls for PowerBuilder 4.0, 5.0 & 6.0
44545 - 32 Bit - Windows API Calls for PowerBuilder 5.0
44648 - Prototyping API Calls for PowerBuilder 4.0, 5.0 and 6.0
44588 - Dynamically Closing a Non-PowerBuilder Application
47703 - GPF's and The PowerBuilder Memory Defragger
47704 - Windows 3.10 and 3.11 Functions - Krnl386.exe, User.exe, Gdi.exe
47707 - 16 Bit - Win95 and NT Functions - Krnl386.exe, User.exe, Gdi.exe
47705 - 32 Bit - Win95 and NT Functions - Kernel32.dll, User32.dll, Gdi32.dll
44474 - Exter






