Copying and working with groups of fields for output

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
dochawk
Posts: 43
Joined: Wed Sep 02, 2009 9:29 pm

Copying and working with groups of fields for output

Post by dochawk » Sun May 20, 2012 1:49 am

My output is repetitive in a mandated form of tables (in print).

I will have some header information, and then fill rows until a page runs out, and then go onto continuation pages.

It seems to make sense to combine each row into a (non-background) group to do this. Call them blocks, A, B, and C, to sit side by side, and perhaps I'll be able to put five rows of blocks on the first page an ten on each additional page.

I'm looking for non-ugly ways to copy them, move them into my output substack, and address them so that I can put output into them.

The only ways I'm seeing to get them onto the card is a repeated sequence of

Code: Select all

select myOutputGroup from card rawStuff of stack printPieces
copy
show stack theOutputStack
paste
set the location of it to nextloc 

or to have fixed output pages, the first and followon, where I cut & paste the entire followon page and clear it when I need another.

What I would *like* to do is create a new substack for output, create pages in it, and then have those pages copy the header, and then the ABC block, fill the ABC block, grab the next, etc', until complete (or perhaps I should have an output stack to start with, so that that stack can hold scripts, then let *it* pull the pieces from other substacks? [but I haven't found a way to create a substack rather than a mainstack by code instead of menu operations]). Then the fields of the firstrow would get named A_1, B_1, and C_1, the next A_2, B_2, and C_2, and so forth.

I've googled incessantly and searched forums & lessons, but everything I keep finding is about the location of text in fields, rather than fields, stacks, and the like. I know I knew a lot of this 20 years ago using HyperCard and SuperCard 1.5, but . . .

I'm rambling. Short version: How do I make a new substack myOutput, create and name newcard myOutP1, and copy the fields A, B, and C of card spareParts of stack rawStuff, aligning their upper left at nextX,nextY, and setting their names to A_1, B_1, and C_1? If I can answer that, I think the rest are corollaries.

thanks

hawk

I also can't find a way to change the "current" stack by scripting (or, for that matter,by anything short of running a script inside of it).

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Copying and working with groups of fields for output

Post by Klaus » Sun May 20, 2012 11:52 am

Hi Hawk,

first: use QUOTES around strings!
second: use QUOTES around strings!
third: you guess! 8)
...
## I bet the card and stack names(sic!) are not variables:
select myOutputGroup OF card "rawStuff" of stack "printPieces"
...

Ok, your questions:
1. Create a stack:
## check CREATE in the dictionary, you can create everything on the fly via script!
## see also "template..."
...
create stack "name of new stack"
...

2. Any new stack already has ONE card, so you just need to name it:
...
set the name of cd 1 of stack "name of new stack" to "new name for card 1"
...

3. Make it a substack, if neccessary and possible, NOT possible in Runtimes!
...
set the mainstack of stack "name of new stack here" to "Name of new MAINSTACK"
...

4. Copy stuff (will only work in Runtimes, if the stacks are not password protected!)
...
## Can be done directly without selecting anything first!
copy grp "my coll group" OF cd "xyz" of stack "zyx" to cd "another card" of stack "yet another stack"
...

5. Make a stack the DEFAULT (Hint, Hint ;-)) for scripts:
...
set the defaultstack to "name of stack you want to address per default"
## This line will now address that namely field on the current card of stack "name of stack you want to address per default"
set the topleft of fld "the field on current card" to 0,0
...

And I still recommend these stacks:
http://www.runrev.com/developers/lesson ... nferences/ 8)


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Copying and working with groups of fields for output

Post by jacque » Sun May 20, 2012 7:19 pm

Klaus is right about not being able to save changes to standalones, but you can go ahead and make the substack in a standalone as long as you know it won't persist across launches.

Another way to do it is to create the substack during development and save it there. Leave it empty. Then it will persist, and you can populate it with fields whenever you need to print.

If your data will always be laid out the same way, then there's more you can do. Create the substack and lay out the fields the way you want them to print. Name each field the same as the corresponding one in the mainstack. This will be a printing template which is permanently saved with the mainstack. Whenever you need to print, just transfer the content of the fields in a repeat loop:

repeat for each item i in "mainfld1,mainfld2,mainfld3" -- as many as you need
set the htmltext of fld i of stack "printTemplate" to the htmltext of fld i of stack "myMainstack"
end repeat

Now the template is populated and you can set the defaultstack to the template stack and print the card. I use htmltext so that any text styling will transfer correctly. If your fields are just plain text without any styling then you can just use "the text of" instead of "the htmltext of". When I use a printing substack it generally contains one card for each layout I need. The script uses the repeat loop to populate the content of the correct template card, then sets the defaultstack and prints. The substack can remain invisible; it isn't necessary to show it in order to work with it or print from it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dochawk
Posts: 43
Joined: Wed Sep 02, 2009 9:29 pm

Re: Copying and working with groups of fields for output

Post by dochawk » Wed May 23, 2012 6:41 pm

Thank you both greatly. This project is now moving faster than expected.

Is there any reason to have a preference between htmlText and styledText?

thanks again

hawk

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Copying and working with groups of fields for output

Post by BvG » Wed May 23, 2012 9:00 pm

styledText is an array, htmlText is like a cheaper cousin to html (but they're not equivalent to each other). StyledText was just introduced, so most people have no experience with using it.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply