Page 1 of 1

The use of third-party libraries in Alaska

Posted: Mon Jul 29, 2013 7:08 am
by Eugene Lutsenko
Can I use the library in Alaska (dll), made ​​in other programming systems, such as Delphi?
How do I get a library made ​​by Delphi has not issued when linking error:

Code: Select all

D:\ALASKA\AIDOS-X>CLS

D:\ALASKA\AIDOS-X>ARC _Aidos.arc 

D:\ALASKA\AIDOS-X>XPP _DW_N2 

D:\ALASKA\AIDOS-X>ALINK _DW_N2 _Aidos.res /PM:PM 
Alaska 32-Bit Linker Version 1.90.355
Copyright (c) Alaska Software 1997-2009. All rights reserved.

ALINK: fatal error ALK4002: invalid or corrupt file "c:\ALLDLLCH\LC_lib.dll"

Re: The use of third-party libraries in Alaska

Posted: Mon Jul 29, 2013 7:23 am
by Tom
You can't link non-Alaska-DLLs as static DLLs, but this is what you tried to do. Functions from 3rd-party-DLLs can be accessed dynamically using the DllLoad()-, DllPrepareCall()-, DllUnload()-mechanism, gathered as the "DLLFUNCTION" statement (see docs). You need to know the parameters and the "calling conventions" for this DLL (standard or C). Just include the function calls and deliver the DLL(s) with your app, that's all. There may be other files/libs/DLLs used by the DLLs, so take a look at the runtime files needed by the product.

Re: The use of third-party libraries in Alaska

Posted: Mon Jul 29, 2013 12:27 pm
by Eugene Lutsenko
Thank you, Tom! Tried to see how these functions and make it right. The program compiles, links, runs and does nothing. No errors to be. What is it? Prompt? The called function simply creates a text file of blank lines, but is needed because it can create files larger than 4GB.

Code: Select all

PROCEDURE AppSys
// Рабочий стол остается окном приложения
RETURN

******************************************************************
FUNCTION Main()

DC_IconDefault(1000)

nDll = DllLoad( "LC_lib.dll" )
IF nDll = 0
   MsgBox('Не найдена динамическая библиотека: "LC_lib.dll"')
   RETURN NIL
ENDIF

N_Rec = 20               // Число признаков
N_Cls = 10               // Число классов
N_Col = N_Cls+3          // Число полей

******** Структура создаваемой базы
aStructure := { { "Kod_pr", "N", 15, 0},;   // 1
                { "Name"  , "C",250, 0} }   // 2
FOR j=1 TO N_Cls
    FieldName = "N"+ALLTRIM(STR(j,15))
    AADD(aStructure, { FieldName, "N", 19, 3 })
NEXT
AADD(aStructure, { "Summa", "N", 19, 0 })

Str_len = 0
FOR j=1 TO N_Col
    Str_len = Str_len + aStructure[j,3]
NEXT

DllCall( nDll,, "LC_CreateDB", "DB_max.txt", Str_len, N_Rec )

DllUnload( nDll )

RETURN NIL

Re: The use of third-party libraries in Alaska

Posted: Mon Jul 29, 2013 3:46 pm
by Auge_Ohr
Eugene Lutsenko wrote:

Code: Select all

DllCall( nDll,, "LC_CreateDB", "DB_max.txt", Str_len, N_Rec )
Tom talk about "calling conventions" so look at
c:\ALASKA\XPPW32\Source\samples\basics\CAPI\call.c

remember Xbase++ is 32bit and can´t work with 64bit OCX / DLL
32bit mean -2147483648 to +2147483647 which are 4GB
if you use FAT32 you also limited to 4GB File Size

Re: The use of third-party libraries in Alaska

Posted: Mon Jul 29, 2013 7:31 pm
by Eugene Lutsenko
External library is just a 32-bit one. It is written in Delphi and allows you to create text files with the specified name, the string length and the number of lines of all sizes, including more than 4GB. But the function does not start at all.

When called by DllCall () nothing happens, and with the macro writes about an error that the function is not declared. Where it is not declared? How to declare it?

Image

Code: Select all

PROCEDURE AppSys
// Рабочий стол остается окном приложения
RETURN

******************************************************************
FUNCTION Main()

LOCAL nDll, cCall, i, p1 := 100, p2 := Space(10) , Str_len := " ", N_Rec := 10

DC_IconDefault(1000)

nDll = DllLoad( "LC_lib.dll" )
IF nDll = 0
   MsgBox('Не найдена динамическая библиотека: "LC_lib.dll"')
   RETURN NIL
ENDIF

N_Rec = 20               // Число признаков
N_Cls = 10               // Число классов
N_Col = N_Cls+3          // Число полей

******** Структура создаваемой базы
aStructure := { { "Kod_pr", "N", 15, 0},;   // 1
                { "Name"  , "C",250, 0} }   // 2
FOR j=1 TO N_Cls
    FieldName = "N"+ALLTRIM(STR(j,15))
    AADD(aStructure, { FieldName, "N", 19, 3 })
NEXT
AADD(aStructure, { "Summa", "N", 19, 0 })

Str_len = 0
FOR j=1 TO N_Col
    Str_len = Str_len + aStructure[j,3]
NEXT

*DllCall( nDll,, "LC_CreateDB", "DB_max.txt", Str_len, N_Rec )

&("LC_CreateDB")("DB_max.txt", Str_len, N_Rec )

DllUnload( nDll )

RETURN NIL

Re: The use of third-party libraries in Alaska

Posted: Tue Jul 30, 2013 5:27 am
by Eugene Lutsenko
Displays a window with empty parameters, which would be a way to not use the call:
Image