VB Script Function

446 views
Skip to first unread message

Mike

unread,
Jun 12, 2009, 9:41:53 AM6/12/09
to XMPie Interest Group
Hello all,

Here is my problem:
I have a postcard mailing project and I in an attempt to aid our
production staff in sorting, traying, bundling of the output I'd like
to have an asterisk appear with the last number of either a tray or
bundle.

I've never found much XMPie documentation on using "Functions" within
uPlan, but I see that you can use Javascript, VB, or Qlingo.

I am familiar with VB and Javascript, but not in the context of XMPie
functions so I'm a bit lost at the moment.

I believe all I need is a loop that will take, for example, Tray # for
record 1 and compare it to Tray # for record 2. If they are equal,
display "*" else display "".

Simple, yet I'm at a loss as to weather XMPie can do ForNext loops or
even look forward to the next record in the data.

Any help or direction is greatly appreciated!

Thank you,
Mike

Gregg Rolando

unread,
Jun 12, 2009, 9:48:10 AM6/12/09
to xmpie...@googlegroups.com
Mike;

As an alternative why not just print the tray and bundle number near the
address on each piece?

Most mailing software will allow this type of export.

Gregg

Mike

unread,
Jun 12, 2009, 10:24:49 AM6/12/09
to XMPie Interest Group
Believe me, I'm right there with you.

This is just a way to "flag" the beginning/ending pieces of the
mailing.

Igor Vorobeychik

unread,
Jun 12, 2009, 10:18:39 AM6/12/09
to XMPie Interest Group
You can achive loops with QLingo , but in order to do that you need
create QLingo recursive function, check uPlan User Guide and see
example of Factorial Function (in uPlan click on Help menu). Now
recursive functions can become tricky and are not always recommended
for Script languages due to stack limitations (at least it was in the
past).

First read Working with Plan Function in the user guide , than once
you can create function and pass it parameters choose any language ,
just for JavaScript and VB Script , you'll not be able to Validate it
in the plan , so you'll have to create proofset to check it.
I personally like Javascript since it has lots of string manipulation
capabilities and examples on the Web. How to use Javascript Functions
in the plan you'll find example in the same guide "Using Functions to
Verify an ID Number".

Gregg Rolando

unread,
Jun 12, 2009, 10:29:18 AM6/12/09
to xmpie...@googlegroups.com
So it is a "break mark' that you are attempting, why not add the break mark in your export from your mailing software then, then add it to your print layout?

Mike

unread,
Jun 12, 2009, 10:49:44 AM6/12/09
to XMPie Interest Group
Gregg you are my hero.

Insert pic of me with donkey head here :)

I never even thought to look at that column in my data.

Already there.

Huge thank you for such a simple solution.

Happy Friday!

Bill

unread,
Jun 13, 2009, 3:32:32 AM6/13/09
to XMPie Interest Group
Hello,

Your post refers to three separate items:
* using Functions in uPlan;
* doing loops in a Plan;
* retrieving data from previous/next recipient.

A. Using Functions in uPlan
===========================
QLingo, VBScript or JavaScript functions calls by an ADOR or a plan
variable are as simple as this:
1. Define your function name (e.g.: myFunc), with the appropriate data
type (string, numeric, date, boolean)
2. Define as many parameters as needed; name each of them (e.g.:
myParam1, myParam2); assign them their appropriate data type;
3. In your QLingo, VBScript or JavaScript function "body":
3a. use your parameter by simply mentioning their names (e.g.:
myParam1, myParam2); current limitation: it is not possible to drag-&-
drop the parameters into the function body; but manually coding the
parameter names - while avoiding typo ;-) - obviously works fine.
3b. In VBScript or JavaScript, define and use as many local variables
as needed (e.g: myVara, myVarb, etc.)
4. To set the return value:
4a. In your VBScript or JavaScript function "body", assign the
function result with the "equal" operator (e.g.: myFunc = myVara)
4b. In your QLingo function "body", just return the calculated value
(e.g.: SubString(myParam1, myParam2, 100)).
5. In your ADOR or variable QLingo code , just call the function, by
mentioning its name and providing the appropriate values for the
expected parameters (e.g.: myFunc(|->[myField], "xxx"))

B. Doing loops in a plan
========================
I would create VBScript or JavaScript functions, which can simply
implement loops.
QLingo does not simply (as "For" or "While" keywords do not exist).

C. Retrieving data from previous/next recipient
===============================================
If your data source can be sorted (which is fairly easy, as soon as
you process it through a plan filter, which contains an SQL "ORDER BY"
statement), and if your data source has a field, which contains a
sequential numbering of each of your recipients (1, 2, 3, ..., n), it
would also be fairly easy to retrieve data from the current or next
recipient, through a plan User View, and a plan variable:
"Previous" variable: |->[myField] -1
SQL query of the "uv_Previous" User View:
SELECT * FROM [myTable] WHERE [myTable].[myField] = @{Previous}
QLingo code of an ADOR or plan variable using the User View:
if (|->[myData]) = [uv_Previous].[myData])
xxx
else
yyy

Alan

unread,
Mar 6, 2014, 11:13:28 PM3/6/14
to xmpie...@googlegroups.com
Bill's guide to functions was short but highly valuable. Far better than the user guide. I know it was five years ago but I had to say thank you!!

Reply all
Reply to author
Forward
0 new messages