Metacard to Livecode

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller

DDS
Posts: 5
Joined: Mon Sep 18, 2017 9:57 am

Metacard to Livecode

Post by DDS » Mon Sep 18, 2017 3:49 pm

Hello everyone,

Last week, I have been asked to convert (least effort) an application from Metacard (2.0) on AIX to a Linux CentOS 6.3. The application has its UI written in Metacard and its main (and interface with other applications) written in (non ANSI) C. The C part starts Metacard (several stacks but only one is displayed at once) and can send messages to it while the Metacard can make external call to the C code.

From what I have read, Livecode is an evolution of Metacard and should be able to understand it. When I load the old .mc scripts in livecode 6.0.1, I don’t see any error (other than external call to the C code), so I guess that works. Converting from the non ANSI C to ANSI C should be straightforward (even if it’s tedious).

However, where there are several things I’m worried about:
1) Calling C from Livecode: I have read the desktop externals guide, but it seems very different from what I already have in the project. Has anything changed between Metacard and Livecode, or should my existing code already work? (The differences I see is because it’s done more nicely with macro and such)
2) Calling Livecode from C: the old app used an “X_init” call from Metacard to start the stacks and messages sent to metacard to control them. Can I do something close? I recall reading that you can’t call Livecode function from an external app, but I can’t find where. Same question for the messages, can I send them to Livecode in order to control the app from the C?
3) Last question: if I type “livecode stack.mc” in a terminal, it open my stack in edition mode (with all the livecode IDE). Is there an option to execute the stack as if it was built as standalone? Or will I have to always build the standalone application?

Thank you for your time,
DDS

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5957
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Metacard to Livecode

Post by FourthWorld » Mon Sep 18, 2017 4:21 pm

MetaCard and LiveCode are the same engine with different IDE stacks. There may be a few changes you'll need to make when updating for the more recent engine versions, but the team has done an excellent job maintaining backward compatibility with the language, so you should find most things will continue to work well.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 1799
Joined: Sat Feb 25, 2017 10:45 pm

Re: Metacard to Livecode

Post by bogs » Mon Sep 18, 2017 4:59 pm

As Richard says, anything older *should* move up with minor if any changes needed, but there are some gotchas to keep in mind, one of those being if you need to access code backwards after going forrwards.

For instance you mentioned you were using livecode 6.0.1 to load the older .mc stacks. If you save the stack from 6.0.1 with the regular 'save stack', anything earlier than that will not see the stack as a stack. Instead it will report it is not a stack or it is corrupted.

If you want to make sure you maintain backwards compatibility, then using the 'save as' menu will go a long ways since that can save back to the Lc 2.4 format. Unfortunately, I am not sure if this is compatible with 2.0 Mc, but all the Lc's up till 8.x can work with that format.

The downside is you loose any new 'features' present in later Lc builds.

Still too new to answer your other questions for the most part, 3. I believe is because Lc's ide is what is associated with your stack. I would be inclined to make a launcher stack and call that to open your working stack, but there may be good and valid reasons why you shouldn't. :(

I am sure wiser and more experienced minds will chirp in shortly though :)
Image

DDS
Posts: 5
Joined: Mon Sep 18, 2017 9:57 am

Re: Metacard to Livecode

Post by DDS » Tue Sep 19, 2017 3:10 pm

Thanks for the advice, but I think we won’t need backward compatibility.
For 3), I had thought about building a new stack that controls the existing ones and starting that from the main (or replacing the main with that), but I’m not sure how it will work concerning the interactions with the C code (see below).

Precisions about the current app: (relevant to my 3 questions)
The application was built using “embedded metacard”: it comes with a metacard engine and a library (libmc.a) (+ a header XCmdGlue?) which allow the C app to interact with the engine. It allows the main to start the engine (the X_init) with parameters such as the stacks to use and a correlation array between the function called in metacard and the pointer to the relevant function in the C code. The MC part uses the array to call the C function, while the C part uses the metacard lib to call (via message) the MC function. I haven’t seen anything like it in Livecode, which worries me. (Since I discovered both Metacard and Livecode a few days ago, I’m not sure about anything)

I think the desktop external can replace the engine for MC calls C part (still working on the how and the tutorial confuses me) but is it possible to easily send messages/signals from the C to Livecode?

bogs
Posts: 1799
Joined: Sat Feb 25, 2017 10:45 pm

Re: Metacard to Livecode

Post by bogs » Tue Sep 19, 2017 4:14 pm

Well, I haven't plodded through any version of C in more than 30 years, and doubt at this point I could write any that would get me out of a wet paper bag without a LOT of re-learning, I am fairly confident that it is possible fairly easily, just as it was done in Mc. I am not sure what the method would be, though, sorry :(
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4441
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Metacard to Livecode

Post by jacque » Tue Sep 19, 2017 4:51 pm

Externals have changed a bit since MC so it would probably need to be rewritten. On the other hand,
LC has so many more features now it may be possible to drop the external entirely and write its functionality in LC. That would all depend on what exactly the external does. Alternately there are a few folks you might be able to hire to rewrite the external if you want to do that.

Once the external is working properly it will communicate in either direction as you expect.

To simulate how the app will run without the LC IDE, you can choose to remove the IDE temporarily from (I think) the development menu. Not at a computer right now so you'll need to poke around to find a menu item that hides the IDE stacks. (I'm betting someone tells you before I get to my office.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 1799
Joined: Sat Feb 25, 2017 10:45 pm

Re: Metacard to Livecode

Post by bogs » Tue Sep 19, 2017 7:16 pm

I believe it is "suspend dev tools" on the bottom of the development menu :)

Doesn't -ui do the same thing? I could be thinking of something else, Richard tried to explain that one to me some time ago :(
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4441
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Metacard to Livecode

Post by jacque » Tue Sep 19, 2017 7:47 pm

bogs wrote:I believe it is "suspend dev tools" on the bottom of the development menu :)

Doesn't -ui do the same thing? I could be thinking of something else, Richard tried to explain that one to me some time ago :(

Right, "suspend development tools."

The -ui flag is for use on servers using LC as a CGI engine. The -ui is a flag that tells LC to launch without a graphical interface. This is different than just disabling the IDE temporarily.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 1799
Joined: Sat Feb 25, 2017 10:45 pm

Re: Metacard to Livecode

Post by bogs » Wed Sep 20, 2017 4:36 am

Ahhhhhhh, THAT is where I was missing the connection! Thank you Jacque :)
Image

DDS
Posts: 5
Joined: Mon Sep 18, 2017 9:57 am

Re: Metacard to Livecode

Post by DDS » Wed Sep 20, 2017 10:08 am

I won’t be able to drop the C-LC interface: the C part was using C libraries from another app (each app sending and receiving requests/data), so I would have to use those directly in Livecode, which doesn’t change much of my problem.
I’ll try to convert one of the smaller stack (rebuilding the external) and see if I can make it work. I’ll keep this thread updated on my progress (or problems) but it might take some time.

Aside: I got a private message, but can’t access it because “You are not authorised to read private messages.” Since this is the only thread I’m participating in, I guess the sender reads it, so:
A) Sorry Sender, but I can’t read it. :(
B) Why can’t I read my PM? I get not being able to send them immediately, but I can’t harm anyone reading those I receive. Or do people here bite in PM (but are nice in public :)) and that “feature” protects me?
C) How can I read my PM? I suppose I need a number of post to be worthy of it, but how many?

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Metacard to Livecode

Post by Thierry » Wed Sep 20, 2017 10:18 am

DDS wrote: Aside: I got a private message, but can’t access it because “You are not authorised to read private messages.”
Hi DDS,

I was the sender.

You can mail me: th [dot] douez [at] sunny-tdz [ dot] com
and I'll write back to you.

Regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

DDS
Posts: 5
Joined: Mon Sep 18, 2017 9:57 am

Re: Metacard to Livecode

Post by DDS » Thu Sep 28, 2017 11:00 am

Hello again,

I managed to check that the conversion is possible and i have an good idea of how to do it/how long it will take (actually, i did not have to convert the app, just study if/how it is possible). It should be enough for now (until I or another have to actually convert the thing).

Thierry : Apologies for not contacting you, my hierarchy advised asked me not to.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Metacard to Livecode

Post by Thierry » Thu Sep 28, 2017 11:04 am

DDS wrote: Thierry : Apologies for not contacting you, my hierarchy advised asked me not to.
Thanks for the feedback and good luck with your project!

Regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

bogs
Posts: 1799
Joined: Sat Feb 25, 2017 10:45 pm

Re: Metacard to Livecode

Post by bogs » Thu Sep 28, 2017 1:26 pm

DDS wrote:B) Why can’t I read my PM? I get not being able to send them immediately, but I can’t harm anyone reading those I receive.
Wondering if this got sorted out? I don't remember having this issue myself when I joined not so long ago.
Image

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Metacard to Livecode

Post by Thierry » Thu Sep 28, 2017 1:42 pm

bogs wrote:
DDS wrote:B) Why can’t I read my PM? I get not being able to send them immediately, but I can’t harm anyone reading those I receive.
Wondering if this got sorted out?
my guess is 7 or 10 posts will do it!

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Post Reply

Return to “Converting to LiveCode”