Inline <<fields>>

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Inline <<fields>>

Post by Philhold » Thu Mar 05, 2009 3:54 pm

Hi,

I'm new to RR, do a bit of Perl, HTML and Filemaker.

I have a Filemaker application and am considering converting this to RR and an SQL database. In order to teach myself about RunRev I've decided to try to make one of the elements of my Filemaker application.

This is a contact management database which links to a database containing all of the letters and other communications we have with a client. The letters are in effect form letters and use "merge fields" which allow for a letter to pull in name, address, date and other relevant information.

I can't find reference to this type of templating or substitution in RunRev. Is there an easy way to do it. In Perl I would use TemplateToolkit or a here doc with the variables inline.

I know that Quartam Reports might be a solution is there a simple way to do variable substitution in RunRev?

Thanks

Phil

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 05, 2009 4:06 pm

Hi Phil,

Since Revolution isn't only a database system but much more a programming environment, you need to make such a system yourself. Usually, I take a text and add a few unique place holders (<<fieldname>>, or simply ***), and use the replaceText function or the replace command to replace the place holders with the text I need.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Mar 05, 2009 4:09 pm

That's what I was about to say, but there's also a great series of articles about using "merge" by Jan Schenkel in the RevUp Newsletter issues:

http://runrev.com/newsletter/august/iss ... etter2.php

http://www.runrev.com/newsletter/novemb ... etter3.php

http://www.runrev.com/newsletter/decemb ... etter3.php

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Thu Mar 05, 2009 6:03 pm

Hi,

Thanks for the prompt replies.

If you read the docs for the Perl modules that do templating such as TemplateToolkit and HTML::Template they all say that "everyone has tried to make their own Perl templating system using a variable replace at some time or other ...". They then go on to tell you that there is no need to start from scratch etc.

I thought that the same might be the case with Runtime Revolution. Off to write my own replace function.

Cheers

Phil

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Thu Mar 05, 2009 6:21 pm

Before you write your own, do take a look at the merge function. It's quite powerful, and makes shortwork of doing a lot of replacements in a template.

You may find many ways to augment that with your own scripts, but speaking as someone who makes a big part of my living with tools to merge data into web templates (my WebMerge product) I can't say enough good things about the usefulness of Rev's merge function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Thu Mar 05, 2009 10:47 pm

Thanks for the pointer Richard.

Here's what I did:

Created 3 fields:
name
text_letter
merged

and a button to make the script go.

This is the script
on mouseUp
put merge (field "text_letter" ) into field merged
end mouseUp


This is the text:
[[field "name"]] more text.

On pressing the button the text with the contents of the "name" field merged in are placed into the "merge" field. This is the behaviour that I was looking for.

Many thanks

Phil

Post Reply