Need help on how can I build an extension for my external dll and call it on my livecode builder

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
jpags.me
Posts: 8
Joined: Thu Jan 31, 2019 7:42 am

Need help on how can I build an extension for my external dll and call it on my livecode builder

Post by jpags.me » Tue Mar 05, 2019 6:27 am

I have a dll file with a function to multiply 2 numbers just for a proof of concept. How do I do it?

I have this strip of code I wrote but it is giving some errors.

Code: Select all

library test_new_lcb

use com.livecode.foreign

private __safe foreign handler _Hello(in pName as string) returns string binds to "new_dll>Hello"


public handler _Hello() returns String
	variable name as pName
	_Hello(name)
	answer(name) 
end handler

end library
Is there something wrong with this code? Please help with this. I am stuck on this for 2 days now.

sphere
Posts: 1047
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Need help on how can I build an extension for my external dll and call it on my livecode builder

Post by sphere » Wed Mar 06, 2019 1:19 pm

i wish i could help you.
I did all the lessons on the livecode builder and that worked, but i would really not know how to uase a dll form any api or whatever and connect it with LC builder.
Maybe you can look at some other examples here on the forum, or look for trevore devore on github. He did some things also connecting to certain dll's, maybe it helps you.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 986
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Need help on how can I build an extension for my external dll and call it on my livecode builder

Post by trevordevore » Wed Mar 06, 2019 2:58 pm

@jpags.me - `string` is not a valid variable type for foreign handlers. You can use ZStringNative, ZStringUTF8, or ZStringUTF16. This file lists them and has descriptions:

https://github.com/livecode/livecode/bl ... -naming.md

A reference to ZString should appear in the LCB guide but I don't see it listed:

https://github.com/livecode/livecode/bl ... n-handlers

Here are some files that bind to DLLs on Windows that should provide some guidance.

Take a look at my WinSparkle repo on GitHub:
https://github.com/trevordevore/lc-wins ... parkle.lcb

These two are from the LiveCode repo:

Timezone.lcb: https://github.com/livecode/livecode/bl ... mezone.lcb

ini.lcb: https://github.com/livecode/livecode/bl ... ni/ini.lcb
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

jpags.me
Posts: 8
Joined: Thu Jan 31, 2019 7:42 am

Re: Need help on how can I build an extension for my external dll and call it on my livecode builder

Post by jpags.me » Thu Mar 07, 2019 4:17 am

Thank you guys! I will take a look at these and understand it all.

Post Reply

Return to “LiveCode Builder”