Jump to content

How Can I Create a Function?


dreimer

Recommended Posts

I want to have this rule available to all jobs in Fusion Pro without having to copy and paste it everytime. The field will always be the same from my data.

 

"return MakeDataMatrixBarcode(Field("Sequen"), null, null, null, 7, null, null)"

 

Can this be done, I tried writing a .js file myself and putting the .js file in the plug-ins folder but it doesn't return anything. Thanks in advance for any help!!

 

Forgot to mention that I would need the Tagged Text box check as well.

Edited by dreimer
Edit
Link to comment
Share on other sites

You were correct to create a .js file and place it in the plug-ins folder, but a function looks a bit different than a rule. Your rule would need to be written as:

function customDataMatrix() {
  return MakeDataMatrixBarcode(Field("Sequen"), null, null, null, 7, null, null);
}

After placing the file in your plug-in folder and restarting FusionPro, the rule would appear in the Building Blocks dialog under the Functions tab in the (Globals) section. You would still need to create a rule in each job and check the tagged text box manually, but the rule would simply be written as:

return customDataMatrix();

 

Alternatively, you could keep (a copy of) the .dif file handy from a previous job that had your custom rule and when linking to data in a new template, you would choose to "Import a data source from another document" via the Wizard, choose the existing .dif file and then go back and pick the actual data file (if applicable) for the new project. Doing that will import all the rules from your former template so that you do not have to re-write the rule.

Link to comment
Share on other sites

The last paragraph in my previous post is probably a better way to accomplish what you were after. Not sure if that's what you settled on or not. :)

 

I know a someone who keeps a .dif file containing all her "most used" rules in her documents folder which she imports for every new job she works on. She may not need all the rules it imports for every job, but it guarantees the common rules she does need will always be there when called upon.

Edited by esmith
Link to comment
Share on other sites

I have used the method for creating a new job from a previous dif file, but this is a rule I would want available for every job no matter what rules were built in previous templates on a job per job basis.

 

Looking through the manual I think this can be accomplished if I edit the RulesTemplate.English.js file. Is this correct and has anyone tried this before?

 

Thanks for any help.

Link to comment
Share on other sites

I figured it out, using the RulesTemplate.english.js file! This will be a great to use for rules I want to create for many of my jobs. I added this to the end of the file and it seems to work.

 

FusionPro.RuleTemplates["Make2D"] =
{
 description:
   "Create 2D Barcode.",
 syntax:
   "return MakeDataMatrixBarcode(Field(\"fieldname\"), null, null, null, 7, null, null);",
taggedtext:1,
 istext:1,
 isgraphic:0
}

 

I actually now changed it to find my exact field name that will be the same for every job and now I don't have to make any edit to the rule, just add it.

Edited by dreimer
Update
Link to comment
Share on other sites

Novice skills showing up again!!!

 

Wanted to do the same for my MAC but can't figure out where to get this done???

 

I don't see that same .js file in the location the manual says it is on the MAC.

 

Found it, for anyone that may want to know here it is:

 

/Library/Application Support/Printable/FusionPro

Edited by dreimer
Update
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...