Background Fields during Import

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mf2k
Posts: 3
Joined: Sat Aug 02, 2014 9:45 pm

Background Fields during Import

Post by mf2k » Sat Aug 02, 2014 9:54 pm

I'm running LiveCode version 6.7.0 dp5. I'm trying to import an old Hypercard stack to get started. I am running into lots of problems and have many questions. I'll start with the biggest issue. My stack has a single background and about 18 000 cards. When I go to the previous card, or indeed any card but the last card, the fields all disappear. Is there a concept of background fields in LiveCode or are they somehow only on a single card?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Background Fields during Import

Post by jmburnod » Sat Aug 02, 2014 11:07 pm

Hi mf2k,
Is there a concept of background fields in LiveCode or are they somehow only on a single card?
Yes.
The equivalent of the hypercard background in Live Code is groups with background behavior.
To manage it have a look at "group","backgroundbehavior", "place group" in the LC dictionary
Best regards
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Background Fields during Import

Post by dunbarx » Sat Aug 02, 2014 11:14 pm

Hi.

This is likely the single greatest difference in simply translating HC concepts to LC ones. So much is similar; this one requires just a bit of rethinking.

Know also that in HC, 18,000 cards was no big deal. But in LC, you will notice a slowdown with such a large, er, stack. This has always, been, to me, the single greatest weakness of LC. You are good with a handful of thousands of cards or so, though. No speed hit at that level.

Fortunately, there are simple workarounds, mainly using external files or SQL. Others will be more conversant with that sort of thing.

Craig Newman

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Background Fields during Import

Post by jmburnod » Sun Aug 03, 2014 12:14 pm

Hi,
I understand you have one background for 18'000 cds.
As said Craig, you can have just one card and external files.
When you go to an other content you have just to import what you want in this cd 8)
For text:

Code: Select all

put url("file:" & MyPathFile)  into fld "MyField"
For image:
reference file way

Code: Select all

set the filename of img "MyImage" to  MyPathFile
Import image

Code: Select all

import paint from file "MyPathFile"
For sound:

Code: Select all

play MyPathFileSnd
or

Code: Select all

set the filename of player "MyPlayer" to MyPathFileSnd
Best regards
Jean-Marc
https://alternatic.ch

mf2k
Posts: 3
Joined: Sat Aug 02, 2014 9:45 pm

Re: Background Fields during Import

Post by mf2k » Mon Aug 04, 2014 12:53 am

Thanks for the responses. I clearly don't get it. It appears that all of my fields are in a single group and that group is a "background group". But all of the fields disappear when I go to any card but the last card. What am I missing so I can make this work?

mf2k
Posts: 3
Joined: Sat Aug 02, 2014 9:45 pm

Re: Background Fields during Import

Post by mf2k » Mon Aug 04, 2014 12:56 am

To be more clear. My group with all fields has the following object properties checked:
- "Shared Group"
- "Behave like a background"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Background Fields during Import

Post by dunbarx » Mon Aug 04, 2014 3:42 am

Hi.

OK.

Unlike a background in HC, which was a native object class, the whole thing was transposed to the concept of groups. These groups can have many of the attributes of the old backgrounds, but they are owned by the cards they reside on.They do not occupy a "space" of their own.

So you can have a group with its background behavior set to "true", but that does not automatically place it on every card in a stack (backGround). This is a process that you must manage yourself, and is very likely what you are seeing after you finally got your HC stack ported over.

A couple of examples:

1- If, on a new stack, you make a group and set its background behavior, then any new card you make will contain that group. And just like in HC, you may or may not set such properties of, say, a field owned by that group, such as the sharedText. This would operate just as it does in HC. In this sense you would least notice the difference, even though there are no backgrounds at all. One small advantage is that there is only one kind of control; there are no longer "cd fld" and "bg fld" control types. There are only fields.

2- Let's say you already have a stack of many cards. You create a new group somewhere and set its backGroundBehavior to "true". Unlike HC, that group will only reside on the card you created it on. It is just an object on the card. It does NOT automatically appear on each card in the current "backGround", as it would in HC.

There are commands to do this very thing though, and I would like you to look up the "place" command in the dictionary. Try this sort of thing at home. Experiment as I indicated above. You will first find the concept clunky and unintuitive. The loss of that bg object will seem like a catastrophe. But there is great flexibility in the new paradigm. You will see....

Write back with your woes. I bet the carry-over of your HC stack orphaned a group and made it local to one card.

Craig Newman

Post Reply