Jump to content

Reference a Frame in FusionPro Desktop


cschendel

Recommended Posts

How do you reference a frame in JavaScript?

 

I have 20 frames, each named frm1, frm2, frm3, etc. In a rule bound to each of those frames, I'd like to be able to ask for the frame name (almost like a frame.name reference).

 

Is this possible in FusionPro Desktop?

 

Thanks!

Chris

Link to comment
Share on other sites

I have 20 frames, each named frm1, frm2, frm3, etc. In a rule bound to each of those frames, I'd like to be able to ask for the frame name (almost like a frame.name reference).

 

To what end? What are you trying to accomplish?

 

In FusionPro 6.0, you can access properties of named frames in JavaScript rules via the FindTextFrame and FindGraphicFrame functions. (For text, they're actually named text flows, which can contain multiple connected text frames.) And a limited set of those properties are settable in OnRecordStart, including border and fill colors and text contents. You can also do per-flow copyfitting in the OnCopyfit callback rule in all versions of FusionPro.

 

However, standard rules (i.e. not callbacks such as OnRecordStart and OnCopyfit) are only executed on a per-record basis, not a per-frame basis. In other words, you really can't write a rule that's "bound" to a particular frame.

 

Again, if you can explain more about what you're trying to accomplish I might be able to offer more specific suggestions.

Link to comment
Share on other sites

I have written a JavaScript Global function that reads something like;

 

function PlacePhoto(intFrameNum)

{

return CreateResource(intFrameNum + ".tif", graphic);

}

 

I then write a [regular] Rule something like;

 

return PlacePhoto(this.frame.name);

 

The line above is what I am trying to finalize as it doen't currently work. The idea here is that each named frame can use the same regular Rule to call the global function and the parameter is its name.

 

I would also like to do this with calling Text Resources. So, in all, I will have a page with multiple graphics and text frames that will call out their respective resources by using their frame name as the parameter.

 

Am I going about this the hard way?

 

Thanks!

-c

Link to comment
Share on other sites

I have written a JavaScript Global function that reads something like;

 

function PlacePhoto(intFrameNum)

{

return CreateResource(intFrameNum + ".tif", graphic);

}

 

I then write a [regular] Rule something like;

 

return PlacePhoto(this.frame.name);

 

The line above is what I am trying to finalize as it doen't currently work. The idea here is that each named frame can use the same regular Rule to call the global function and the parameter is its name.

 

I would also like to do this with calling Text Resources. So, in all, I will have a page with multiple graphics and text frames that will call out their respective resources by using their frame name as the parameter.

 

Am I going about this the hard way?

That is actually the way I would think to do it too, in an abstract manner.

 

If you're using a version of FusionPro prior to 6.0, then this solution is unfortunately not possible. You'd have to write 20 different rules, one for each frame. That's the hard way.

 

However, if you are using FusionPro 6.0, you can take advantage of the new Frame Properties JavaScript Access feature. In fact, this is an excellent example of how useful that feature is. Just do this in OnRecordStart:

for (var i = 1; i <= 20; i++)
 FindGraphicFrame("frm" + i).SetGraphic(i + ".tif");

It really is that simple!

Link to comment
Share on other sites

Thanks for that solution Dan. I am just starting to make my work easier with JavaScript and have ideas for a solution like this in my own work.

 

Using cschendel's example, how would your simple script be used for multiple records? I'm assuming that there are 20 resources in FP pointing to 20 files on the server which populate the 20 frames in the template, but that would only seem to generate page 1 of the "catalog".

 

I can't wrap my head around how the next 20 images would get populated on page/record 2 using this code. How would/could this example be modified (or does it need to?) for multiple records using a common template?

 

Also, instead of creating resource "links" for every image (assume there were 28 pages, each with 20 unique images), is there a way in the code to specify a path and just pull the images directly from the server?

 

Thanks for sharing your knowledge -- my script curiosity began when I couldn't resist understanding the last line of your signature!

 

return "Ebo!Lpso!jt!b!KT!cfbtu\"".replace(/./g,function(q){return String.fromCharCode(q.charCodeAt()-1)});

Link to comment
Share on other sites

esmith

 

You could do something like;

 

for (var i = 1; i <= 20; i++)
 FindGraphicFrame("frm" + i).SetGraphic(Field(i) + ".tif");

 

This assumes your data columns are named 1, 2, 3 and the values in the data are names of the graphics.

 

-c

Link to comment
Share on other sites

Using cschendel's example, how would your simple script be used for multiple records? I'm assuming that there are 20 resources in FP pointing to 20 files on the server which populate the 20 frames in the template, but that would only seem to generate page 1 of the "catalog".

 

I can't wrap my head around how the next 20 images would get populated on page/record 2 using this code. How would/could this example be modified (or does it need to?) for multiple records using a common template?

Please refer to the section titled "How to return multiple records in the same output file" in the FusionPro Rules System Guide.

Also, instead of creating resource "links" for every image (assume there were 28 pages, each with 20 unique images), is there a way in the code to specify a path and just pull the images directly from the server?

Sure, you can use CreateResource to access any file on your machine or on the network (via UNC on Windows, or via a mounted drive path on Mac).

Thanks for sharing your knowledge -- my script curiosity began when I couldn't resist understanding the last line of your signature!
return "Ebo!Lpso!jt!b!KT!cfbtu\"".replace(/./g,function(q){return String.fromCharCode(q.charCodeAt()-1)});

LOL, thanks!

You could do something like;
for (var i = 1; i <= 20; i++)
 FindGraphicFrame("frm" + i).SetGraphic(Field(i) + ".tif");

This assumes your data columns are named 1, 2, 3 and the values in the data are names of the graphics.

There's something very familiar about that code....

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...