Difference between revisions of "360Works Scribe/Documentation"

From 360Works Product Documentation Wiki
Jump to navigation Jump to search
m (Auto-upload documentation)
m (Auto-upload documentation)
 
Line 9: Line 9:
 
=Function Summary=
 
=Function Summary=
 
<div id="toc">
 
<div id="toc">
 +
*[[#ScribeConvert|ScribeConvert]] ( input ; format { ; key1=value1 ; ... } ) &mdash;
 
*[[#ScribeDifferenceReport|ScribeDifferenceReport]] ( someText ; otherText ) &mdash; Returns a report on the types of differences between two blocks of text.
 
*[[#ScribeDifferenceReport|ScribeDifferenceReport]] ( someText ; otherText ) &mdash; Returns a report on the types of differences between two blocks of text.
 
*[[#ScribeDifferencesBetween|ScribeDifferencesBetween]] ( someText ; otherText { ; options } ) &mdash; Returns the highlighted differences between two blocks of text.
 
*[[#ScribeDifferencesBetween|ScribeDifferencesBetween]] ( someText ; otherText { ; options } ) &mdash; Returns the highlighted differences between two blocks of text.
*[[#ScribeDocAppend|ScribeDocAppend]] ( data { ; key=value } ) &mdash; <i>(Currently only for Microsoft Word)</i>
 
    Appends data to the end of the currently loaded document (see {@link #ScribeDocLoad(com.
 
*[[#ScribeDocCancel|ScribeDocCancel]] &mdash; Closes the currently loaded document without saving any pending changes.
 
 
*[[#ScribeDocListFields|ScribeDocListFields]] &mdash; Lists all fields in the loaded document.
 
*[[#ScribeDocListFields|ScribeDocListFields]] &mdash; Lists all fields in the loaded document.
*[[#ScribeDocLoad|ScribeDocLoad]] ( containerOrUrl { ; password=xxxxx } ) &mdash; Loads a file.
 
 
*[[#ScribeDocReadValue|ScribeDocReadValue]] ( name { ; key=value ; ... } ) &mdash; Reads a field value from the currently loaded file.
 
*[[#ScribeDocReadValue|ScribeDocReadValue]] ( name { ; key=value ; ... } ) &mdash; Reads a field value from the currently loaded file.
 
*[[#ScribeDocSaveContainer|ScribeDocSaveContainer]] ( newName {; flatten=true ; type=file } ) &mdash; Returns the currently loaded file as a container field, applying any modifications.
 
*[[#ScribeDocSaveContainer|ScribeDocSaveContainer]] ( newName {; flatten=true ; type=file } ) &mdash; Returns the currently loaded file as a container field, applying any modifications.
 
*[[#ScribeDocSaveFile|ScribeDocSaveFile]] ( path {; flatten=true } ) &mdash; Saves the currently loaded file to disk, applying any modifications.
 
*[[#ScribeDocSaveFile|ScribeDocSaveFile]] ( path {; flatten=true } ) &mdash; Saves the currently loaded file to disk, applying any modifications.
*[[#ScribeDocSubstitute|ScribeDocSubstitute]] ( searchText ; replaceText ) &mdash; Replaces all occurrences of <code>searchText</code> with <code>replaceText</code> in the currently loaded document.
 
*[[#ScribeDocWriteValue|ScribeDocWriteValue]] ( name ; value { ; key=value ; ... } ) &mdash; Write a field value in the currently loaded file.
 
 
*[[#ScribeFileAsKeywords|ScribeFileAsKeywords]] ( fileOrContainer ) &mdash; Returns a unique list of keywords for the <code>file</code>.
 
*[[#ScribeFileAsKeywords|ScribeFileAsKeywords]] ( fileOrContainer ) &mdash; Returns a unique list of keywords for the <code>file</code>.
 
*[[#ScribeFileAsText|ScribeFileAsText]] ( fileOrContainer{; param1=value1; param2=value2} ) &mdash; Returns the plain text content of the <code>file</code>.
 
*[[#ScribeFileAsText|ScribeFileAsText]] ( fileOrContainer{; param1=value1; param2=value2} ) &mdash; Returns the plain text content of the <code>file</code>.
Line 28: Line 23:
 
*[[#ScribePatternMatchAll|ScribePatternMatchAll]] ( text; regex {; flags=flag1+flag2+flag3+...} ) &mdash; Returns a newline-delimited list containing pattern matches.
 
*[[#ScribePatternMatchAll|ScribePatternMatchAll]] ( text; regex {; flags=flag1+flag2+flag3+...} ) &mdash; Returns a newline-delimited list containing pattern matches.
 
*[[#ScribePatternReplaceAll|ScribePatternReplaceAll]] ( text; regex; replacement {; param1=value1 ; param2=value2 ; ...} ) &mdash; Replace all occurrences of a regex pattern with some replacement text.
 
*[[#ScribePatternReplaceAll|ScribePatternReplaceAll]] ( text; regex; replacement {; param1=value1 ; param2=value2 ; ...} ) &mdash; Replace all occurrences of a regex pattern with some replacement text.
*[[#ScribeRegister|ScribeRegister]] ( licenseKey; registeredTo ) &mdash; Registers the plugin.
 
*[[#ScribeSetErrorCapture|ScribeSetErrorCapture]] ( errorCapture ) &mdash; Toggles error dialogs on or off.
 
*[[#ScribeStyleAddedText|ScribeStyleAddedText]] ( color ; styles { ; open ; close } ) &mdash; Sets the style to use for displaying added text.
 
*[[#ScribeStyleDeletedText|ScribeStyleDeletedText]] ( color ; styles { ; open ; close } ) &mdash; Sets the style to use for displaying deleted text.
 
*[[#ScribeStyleModifiedText|ScribeStyleModifiedText]] ( color ; styles { ; open ; close } ) &mdash; Sets the style to use for displaying modified text.
 
 
*[[#ScribeVersion|ScribeVersion]] &mdash; Returns the version of the plugin which is installed.
 
*[[#ScribeVersion|ScribeVersion]] &mdash; Returns the version of the plugin which is installed.
 
</div>
 
</div>
 
=Function Detail=
 
=Function Detail=
 +
<div id="ScribeConvert"></div>
 +
==ScribeConvert ( input ; format { ; key1=value1 ; ... } ) ==
 +
 +
 +
<div class="parameters"><strong>Parameters:</strong>
 +
<dl></dl></div>
 +
 +
 
<div id="ScribeDifferenceReport"></div>
 
<div id="ScribeDifferenceReport"></div>
 
==ScribeDifferenceReport ( someText ; otherText ) ==
 
==ScribeDifferenceReport ( someText ; otherText ) ==
Line 76: Line 74:
 
</dl></div>
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> Styled text which displays the differences between the two strings, according to highlighting parameters.
 
<div class="see"><strong>Returns:</strong> Styled text which displays the differences between the two strings, according to highlighting parameters.
</div>
 
 
<div id="ScribeDocAppend"></div>
 
==ScribeDocAppend ( data { ; key=value } ) ==
 
<i>(Currently only for Microsoft Word)</i>
 
Appends data to the end of the currently loaded document (see [[#ScribeDocLoad|ScribeDocLoad]]. This is useful if your file template does not contain text to replace, or you want to add a repeating section to a document.
 
 
Optional arguments:
 
 
<code>newPage=true</code>: force a page break before the appended document
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>data</code> <dd>text or image or another document to append to the currently loaded document
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, or "ERROR" if an error occurs.
 
</div>
 
 
<div id="ScribeDocCancel"></div>
 
==ScribeDocCancel==
 
Closes the currently loaded document without saving any pending changes. This releases any in-memory resources or file locks used by the currently loaded document.
 
 
<div class="see"><strong>Returns:</strong> Always returns 1
 
 
</div>
 
</div>
  
Line 113: Line 88:
 
<div class="see"><strong>See also:</strong>  [[#ScribeDocReadValue|ScribeDocReadValue]],  [[#ScribeDocWriteValue|ScribeDocWriteValue]]
 
<div class="see"><strong>See also:</strong>  [[#ScribeDocReadValue|ScribeDocReadValue]],  [[#ScribeDocWriteValue|ScribeDocWriteValue]]
 
</div><div class="see"><strong>Returns:</strong> return-separated list of field names. For Excel documents, this returns the bottom-right cell coordinate.
 
</div><div class="see"><strong>Returns:</strong> return-separated list of field names. For Excel documents, this returns the bottom-right cell coordinate.
</div>
 
 
<div id="ScribeDocLoad"></div>
 
==ScribeDocLoad ( containerOrUrl { ; password=xxxxx } ) ==
 
Loads a file.  You must load a file before calling any of the other <code>ScribeDoc*</code> functions.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>containerOrUrl</code> <dd>container, path (including File URLs), or URL for the file being loaded.
 
<dt><code>args</code> <dd>optional arguments.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 if the file was successfully loaded, or "ERROR" if the an error occurred.
 
 
</div>
 
</div>
  
Line 249: Line 213:
 
<dl></dl></div>
 
<dl></dl></div>
 
<div class="see"><strong>Returns:</strong> FileMaker file path to the saved file, for example 'file:/Macintosh HD/Users/jesse/Desktop/Letter_to_clients.docx'. This can be used with the 'Insert File' script step to insert the file into a container field in FileMaker.
 
<div class="see"><strong>Returns:</strong> FileMaker file path to the saved file, for example 'file:/Macintosh HD/Users/jesse/Desktop/Letter_to_clients.docx'. This can be used with the 'Insert File' script step to insert the file into a container field in FileMaker.
</div>
 
 
<div id="ScribeDocSubstitute"></div>
 
==ScribeDocSubstitute ( searchText ; replaceText ) ==
 
Replaces all occurrences of <code>searchText</code> with <code>replaceText</code> in the currently loaded document.
 
Note that <code>searchText</code> and <code>replaceText</code> should generally should be short pieces of text,
 
which only span one line (for convenience... long search strings can be more complicated to correctly enter into FileMaker calculations).
 
This feature is only available for Microsoft Word 2007 and later (.docx files only).
 
To replace named form fields or cells in a PDF form, Word Document, or other file, use the [[#ScribeDocWriteValue|ScribeDocWriteValue]] function instead.
 
<p class="version2">
 
Word documents support image replacement in Scribe 2.0, you can pass a container as the replaceValue, and an image will be inserted into your Word document.
 
 
To use this, you must first load a document using [[#ScribeDocLoad|ScribeDocLoad]].
 
 
<h4>Image Support in Microsoft Word Files</h4>
 
 
Pass a container as the <code>replaceText</code> to add it to the Word document.
 
 
 
ScribeDocSubstitute("[placeholder]" ; myTable::myContainer )
 
 
 
<h3>Saving the File</h3>
 
After calling <code>ScribeDocSubstitute</code> one or more times, save the modified file using [[#ScribeDocSaveFile|ScribeDocSaveFile]].
 
 
If you need to substitute many different text occurrences, just call this function once for each term that you want to find and replace.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>searchString</code> <dd>text to find
 
<dt><code>replaceValue</code> <dd>text to replace <code>searchString</code> with. Word documents support image replacement as well.
 
</dl></div>
 
<div class="see"><strong>See also:</strong>  [[#ScribeDocLoad|ScribeDocLoad]],  [[#ScribeDocSaveFile|ScribeDocSaveFile]],  [[#ScribeDocWriteValue|ScribeDocWriteValue]]
 
</div><div class="see"><strong>Returns:</strong> 1 on success, or "ERROR" if an error occurs.
 
</div>
 
 
<div id="ScribeDocWriteValue"></div>
 
==ScribeDocWriteValue ( name ; value { ; key=value ; ... } ) ==
 
Write a field value in the currently loaded file.  The behavior of this function depends on the type of document currently loaded (see [[#ScribeDocLoad|ScribeDocLoad]]).
 
 
To use this, you must first load a document using [[#ScribeDocLoad|ScribeDocLoad]].
 
<h3>PDF Support</h3>
 
To write an acrofield on a PDF, pass the name of the acrofield whose value you wish to set as the first parameter.
 
You can also write values to checkboxes and radio buttons. The only values you can write are "Off" or "Yes", and they are case-sensitive.
 
 
To write XMP metadata to a PDF, use the <code>PDFMetadata</code> key, and pass in the XMP xml you wish to write (read this using [[#ScribeDocReadValue|ScribeDocReadValue]]
 
 
 
To write attachments to a PDF, use the <code>PDFAttachment</code> key, and pass in a container to attach to the file. Existing attachments with matching names will be replaced, otherwise a new attachment will be added to the PDF.
 
 
<h3>Word Support</h3>
 
Microsoft Word supports named placeholders in word documents (.docx files only) called Content Control Fields. Pass the
 
<code>tag name</code> of the Content Control Field as the first parameter.  Content control fields can only be
 
created on Office 2007 on Windows, but can be read and written on both Windows and Mac.  More information about how to make content control fields can be found [http://blogs.msdn.com/b/eric_carter/archive/2009/03/24/content-control-event-model-in-word-2007.aspx here].
 
 
To do a find/replace operation on text in a word document, use the [[#ScribeDocSubstitute|ScribeDocSubstitute]] function.
 
 
 
<h4>Table Support in Microsoft Word Files</h4>
 
Use excel-style syntax to refer to table cells in a word document. For example, to write a value to the 3rd row, 4th column of the first table in a Word document:
 
 
ScribeDocWriteValue("Table1!D3", "This is a table cell")
 
 
Writing to non-existent table cells will create new rows/columns as needed, copying cell styles from preceding cells.
 
 
<h4>Image Support in Microsoft Word Files</h4>
 
 
Use [[#ScribeDocSubstitute|ScribeDocSubstitute]] or [[#ScribeDocAppend|ScribeDocAppend]] to add images to a Word document.
 
 
 
<h3>Excel Support</h3>
 
To write values to an excel sheet <b>(.xlsx files only)</b>, pass the coordinates of a single cell, e.g. "<code>A5</code>" as the first parameter.
 
The second parameter can be text or an image in a container field. Images will be placed so the top-left corner of the image is in the cell indicated by the <code>name</code> parameter.
 
 
To specify a sheet other than the first sheet, include the sheet name followed by an exclamation point, e.g. "<code>Sheet 2!BB42</code>".
 
 
Writing a value to a non-existent sheet will generate an error.  If you specify a non-existent cell or row, it will be created.
 
<div class="version2"><strong></stron>To write formulas to an Excel sheet</strong>, preface the value with an equals sign, e.g.
 
 
ScribeDocWriteValue("C3" ; "=SUM(A1,B1)" )
 
 
To explicitly write a value with a leading equals sign, pass "literal" as the optional third parameter.
 
<dl>
 
<dt>wrap
 
<dd>Set to <code>true</code> to wrap newlines in the written text
 
</dl>
 
</div>
 
 
 
<div class="version2"><h3>PowerPoint Support (new in Scribe version 2)</h3>
 
Write images to a PowerPoint file by specifying the sheet number and optional coordinates for the image to add to the PowerPoint presentation. For example, to add an image from a container field to the first slide:
 
 
ScribeDocWriteValue(
 
"1" ;
 
MyTable::MyImage ;
 
"x=100" ;
 
"y=200" ;
 
"width=300" ;
 
"height=400"
 
)
 
 
</div>
 
<h3>XML Support</h3>
 
To write values to an XML document, pass an XPath expression identifying the node to be modified as the first parameter.
 
<div class="version2"><h3>PDF Support (in Scribe 2.0)</h3>
 
Use the following functions to modify a PDF:
 
<h4>Adding Pages to a PDF</h4>
 
 
ScribeDocWriteValue("newPage()" ; "2" )
 
 
<h4>Adding Images to a PDF</h4>
 
 
ScribeDocWriteValue("addImage()" ;
 
my::imageContainer ;
 
"page=2" ;
 
"x=100" ;
 
"y=100" ;
 
"width=300" ;
 
"height=400" )
 
 
<h4>Adding Text to a PDF</h4>
 
 
ScribeDocWriteValue("addText()" ;
 
"Hello, PDF!" ;
 
"page=2" ;
 
"x=200" ;
 
"y=500" )
 
 
</div>
 
<h3>Saving the File</h3>
 
After calling <code>ScribeDocWriteValue</code> one or more times, save the modified file using [[#ScribeDocSaveFile|ScribeDocSaveFile]].
 
<h3>Note:</h3>
 
Due to the nature of writing directly to the document XML, calculations in Excel cells may not fire automatically when the value is written.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>name</code> <dd>field / cell to write to
 
<dt><code>fmValue</code> <dd>data to write
 
</dl></div>
 
<div class="see"><strong>See also:</strong>  [[#ScribeDocListFields|ScribeDocListFields]],  [[#ScribeDocReadValue|ScribeDocReadValue]]
 
</div><div class="see"><strong>Returns:</strong> 1 on success, or "ERROR" if an error occurs.
 
 
</div>
 
</div>
  
Line 626: Line 451:
 
<div class="see"><strong>See also:</strong>  [[#ScribeHighlight|ScribeHighlight]]
 
<div class="see"><strong>See also:</strong>  [[#ScribeHighlight|ScribeHighlight]]
 
</div><div class="see"><strong>Returns:</strong> The input text with all occurrences of <code>regex</code> replaced with <code>replacement</code>
 
</div><div class="see"><strong>Returns:</strong> The input text with all occurrences of <code>regex</code> replaced with <code>replacement</code>
</div>
 
 
<div id="ScribeRegister"></div>
 
==ScribeRegister ( licenseKey; registeredTo ) ==
 
Registers the plugin.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>licenseKey</code> <dd>a valid license key
 
<dt><code>registeredTo</code> <dd>the company the plugin is registered to
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, or <code>"ERROR"</code> on failure.
 
</div>
 
 
<div id="ScribeSetErrorCapture"></div>
 
==ScribeSetErrorCapture ( errorCapture ) ==
 
Toggles error dialogs on or off. When something unexpected happens, the plug-in will pop up a dialog displaying the error message. This makes it easy to see what went wrong. However, in some cases, you (the developer) may prefer to show your own message to the user, or possibly not show a message at all. In that case, you can call ScribeSetErrorCapture with a parameter of <code>True</code>. That will suppress the error dialog from appearing to the user.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>errorCapture</code> <dd>set to true to suppress the default popups.
 
</dl></div>
 
 
 
<div id="ScribeStyleAddedText"></div>
 
==ScribeStyleAddedText ( color ; styles { ; open ; close } ) ==
 
Sets the style to use for displaying added text.
 
<span style="color:rgb(0,200,0)">The default plugin behavior is to display added text as green.</span>
 
This will affect all calls to [[#ScribeDifferencesBetween|ScribeDifferencesBetween]] until you quit FileMaker.
 
 
The available styles are:
 
<ul><li>Plain</li>
 
<li>Bold</li>
 
<li>Italic</li>
 
<li>Underline</li>
 
<li>Condense</li>
 
<li>Extend</li>
 
<li>Strikethrough</li>
 
<li>SmallCaps</li>
 
<li>Superscript</li>
 
<li>Subscript</li>
 
<li>Uppercase</li>
 
<li>Lowercase</li>
 
<li>Titlecase</li>
 
<li>WordUnderline</li>
 
<li>DoubleUnderline</li>
 
</ul>
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>color</code> <dd>a FileMaker RGB value (such as 'rgb(255,0,0)' for red) or HTML-style hex value (such as "#FF0000" for red)
 
<dt><code>styles</code> <dd>Any of the Filemaker style keywords, or -1 to hide text of this type in the diff result.
 
<dt><code>open</code> <dd>An optional text string appended before an addition
 
<dt><code>close</code> <dd>An optional text string appended after an addition
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, or &quot;ERROR&quot; on failure.  Use diffLastError to get more information on the error.
 
</div>
 
 
<div id="ScribeStyleDeletedText"></div>
 
==ScribeStyleDeletedText ( color ; styles { ; open ; close } ) ==
 
Sets the style to use for displaying deleted text.
 
<span style="color:rgb(200,0,0);text-decoration:line-through">The default plugin behavior is to display deleted text as red with a strikethrough style.</span>
 
This will affect all calls to [[#ScribeDifferencesBetween|ScribeDifferencesBetween]] until you quit FileMaker.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>color</code> <dd>a FileMaker RGB value (such as 'rgb(255,0,0)' for red) or HTML-style hex value (such as "#FF0000" for red)
 
<dt><code>styles</code> <dd>Any of the Filemaker style keywords, or -1 to hide text of this type in the diff result.
 
<dt><code>open</code> <dd>An optional text string appended before a deletion
 
<dt><code>close</code> <dd>An optional text string appended after a deletion
 
</dl></div>
 
<div class="see"><strong>See also:</strong>  [[#ScribeStyleAddedText|ScribeStyleAddedText]]
 
</div><div class="see"><strong>Returns:</strong> 1 on success, or &quot;ERROR&quot; on failure. Use ScribeLastError to get more information on the error.
 
</div>
 
 
<div id="ScribeStyleModifiedText"></div>
 
==ScribeStyleModifiedText ( color ; styles { ; open ; close } ) ==
 
Sets the style to use for displaying modified text.
 
<span style="color:rgb(0,0,200)">The default plugin behavior is to display modified text as blue.</span>
 
This will affect all calls to [[#ScribeDifferencesBetween|ScribeDifferencesBetween]] until you quit FileMaker.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>color</code> <dd>a FileMaker RGB value (such as 'rgb(255,0,0)' for red) or HTML-style hex value (such as "#FF0000" for red)
 
<dt><code>styles</code> <dd>Any of the Filemaker style keywords, or -1 to hide text of this type in the diff result.
 
<dt><code>open</code> <dd>An optional text string appended before a modification
 
<dt><code>close</code> <dd>An optional text string appended after a modification
 
</dl></div>
 
<div class="see"><strong>See also:</strong>  [[#ScribeStyleAddedText|ScribeStyleAddedText]]
 
</div><div class="see"><strong>Returns:</strong> 1 on success, or &quot;ERROR&quot; on failure. Use ScribeLastError to get more information on the error.
 
 
</div>
 
</div>
  

Latest revision as of 20:48, 9 May 2017

360Works Scribe User Guide

Scribe is a multi-purpose plugin for reading and manipulating documents, and working with text. See the 'How to use Scribe.fp7' file for step-by-step tutorials.


360Works Plugin Setup Guides

See Plugins_101 for Error reporting, installation, registration, and more.

Function Summary

  • ScribeConvert ( input ; format { ; key1=value1 ; ... } ) —
  • ScribeDifferenceReport ( someText ; otherText ) — Returns a report on the types of differences between two blocks of text.
  • ScribeDifferencesBetween ( someText ; otherText { ; options } ) — Returns the highlighted differences between two blocks of text.
  • ScribeDocListFields — Lists all fields in the loaded document.
  • ScribeDocReadValue ( name { ; key=value ; ... } ) — Reads a field value from the currently loaded file.
  • ScribeDocSaveContainer ( newName {; flatten=true ; type=file } ) — Returns the currently loaded file as a container field, applying any modifications.
  • ScribeDocSaveFile ( path {; flatten=true } ) — Saves the currently loaded file to disk, applying any modifications.
  • ScribeFileAsKeywords ( fileOrContainer ) — Returns a unique list of keywords for the file.
  • ScribeFileAsText ( fileOrContainer{; param1=value1; param2=value2} ) — Returns the plain text content of the file.
  • ScribeHighlight ( text; highlightPattern {; param1=value1 ; param2=value2 ; ...} ) — Highlights all occurrences of highlightPattern in text.
  • ScribeLastError — Returns the last Scribe-related error which occurred.
  • ScribeLicenseInfo — Returns information about the license used.
  • ScribePatternMatchAll ( text; regex {; flags=flag1+flag2+flag3+...} ) — Returns a newline-delimited list containing pattern matches.
  • ScribePatternReplaceAll ( text; regex; replacement {; param1=value1 ; param2=value2 ; ...} ) — Replace all occurrences of a regex pattern with some replacement text.
  • ScribeVersion — Returns the version of the plugin which is installed.

Function Detail

ScribeConvert ( input ; format { ; key1=value1 ; ... } )

Parameters:


ScribeDifferenceReport ( someText ; otherText )

Returns a report on the types of differences between two blocks of text. This will always return three return-separated values: additions, modifications, deletions. Each line consists of a label, edit count, and character count.

For example, the following report:

additions: 2 214
modifications: 0 0
deletions: 1 47

Indicates that:

  • 2 blocks were added, for a total of 214 characters
  • No modifications
  • 1 deletion, of 47 characters
Parameters:
someText
initial text
otherText
modified text
Returns: report on the number of differences between the two blocks of text.

ScribeDifferencesBetween ( someText ; otherText { ; options } )

Returns the highlighted differences between two blocks of text. Any text which is in 'otherText' but not in 'someText' is considered an addition, and is styled according to the ScribeStyleAddedText style. Any block of text which has changed from 'someText' to 'otherText' is considered modified text, and is styled according to the ScribeStyleModifiedText style. Any text which is in 'someText' but not in 'otherText' is considered a deletion, and is styled according to the ScribeStyleDeletedText style.

Custom Options

Pass "verbose=true" as a custom option to cause modifications to be displayed as a delete then an insert, instead of a modification.

Parameters:
someText
intial text
otherText
revised text
options
options
Returns: Styled text which displays the differences between the two strings, according to highlighting parameters.

ScribeDocListFields

Lists all fields in the loaded document.

PDF Support

Returns any named acrofields.

Word Support (Office 2007 format or later. Works with .docx files only.)

Returns any named placeholder tags.

Excel Support (Office 2007 format or later. Works with .xlsx files only.)

Returns a list of sheets in the excel document.

Returns: return-separated list of field names. For Excel documents, this returns the bottom-right cell coordinate.

ScribeDocReadValue ( name { ; key=value ; ... } )

Reads a field value from the currently loaded file. The behavior of this function depends on the type of document currently loaded (see ScribeDocLoad).

PDF Support

To read an acrofield from a PDF, pass the name of the acrofield whose value you wish to retrieve.

To read metadata values, use the respective name parameter:

  • PDFPageCount - The number of pages.
  • PDFTitle - The document's title.
  • PDFAuthor - The name of the person who created the document.
  • PDFSubject - The Subject of the document.
  • PDFKeywords - Keywords associated with the document.
  • PDFCreator - The name of the application that created the document.
  • PDFProducer - If the document was converted to PDF from another format, the name of the application that converted it to PDF.
  • PDFCreationDate - The date and time the document was created, in human-readable form.
  • PDFModDate - The date and time the document was most recently modified, in human-readable form.
  • PDFImageCount - The Number of images in the PDF.
  • PDFImage[n] - The nth image in the PDF file.
  • PDFMetadata - The XMP metadata associated with this PDF, if applicable.
  • PDFAttachmentNames - A return-separated list of attachments in the PDF.
  • PDFAttachment - A single attachment. You must pass in a 'filename' parameter indicating the name of the attachment you want.

Note: the descriptions for the fields above are suggested by PDF standards community, but may not strictly represent the values in those fields.

Word Support (Office 2007 format or later. Works with .doc and .docx files.)

Microsoft Word supports named placeholders in word documents called Content Control Fields. Pass the tag name of the Content Control Field as the parameter. Content control fields can only be created on Office 2007 on Windows, but can be read and written on both Windows and Mac. More information about how to make content control fields can be found here.

Table Support

Read values from a specific table cell in Microsoft Word using Excel-style syntax, e.g. to read the 3rd column of the 15th row of the first table in a Word document:

ScribeDocReadValue("Table1!C15")

Excel Support (Office 2007 format or later)

To read values from an excel sheet, pass the coordinates of a single cell, e.g. "A5".

To specify a sheet other than the first sheet, include the sheet name followed by an exclamation point, e.g. "Sheet 2!BB42".

New Excel Features in Scribe 2.0

To read a range of values as CSV, specify the start and end columns delimited by a colon, e.g. A1:C15. Optionally, pass "invert=true" as an additional parameter to read rows-first instead of column-first. Optionally, pass "rowSeparator=x" or "fieldSeparator=y" as additional parameter to specify custom delimiters.

ScribeDocReadValue("A1:C15" ; "fieldSeparator=|")


To get the maximum bounds of a worksheet, request MaxRow( ) or MaxCol ( ). Optionally, pass in worksheet=... as an additional parameter, for example:

ScribeDocReadValue("MaxRow()" ; "worksheet=Second Sheet" )


To read a cell's formula (instead of the formula result), pass "formula" as an optional parameter, e.g.

$c3Formula = ScribeDocReadValue( "C3" ; "formula" ) // SUM(A1,B1)

This will return the formula text, if one is specified on the cell.


To read cell comments, pass "commentText" as an optional parameter, e.g.

$c3Comment = ScribeDocReadValue( "C3" ; "commentText" )

This will return the color as a numeric value, which you can pass to FileMaker as a


To read cell background colors, pass "background" as an optional parameter, e.g. to read a cell value and then style some FileMaker text the same color:

$c3BackgroundColor = ScribeDocReadValue( "C3" ; "background" )
# $c3BackgroundColor is a numeric color value, we can use it to style some text
TextColor ( myTable::sampleField ; $c3BackgroundColor )


XML Support

To read values from an XML document, pass an XPath expression identifying the node to be modified as the first parameter.

Parameters:
name
attribute name to read.
Returns: value of the named attribute in the currently loaded file, or "ERROR" if an error occurs.

ScribeDocSaveContainer ( newName {; flatten=true ; type=file } )

Returns the currently loaded file as a container field, applying any modifications. This closes the document after saving it to a temporary folder.

The newName parameter tells Scribe what to name the container field value. This can take two forms:

  • It can be empty, like this: ScribeDocSaveContainer(""). That tells Scribe to keep the original filename.
  • It can be just a filename, like this: ScribeDocSaveContainer("MyNewFile.doc"). That tells Scribe to return a container field with this new filename.

The optional flatten parameter can be used with PDF forms to save a "flattened" version of the form, this would make the form fields unenterable.

The optional type parameter can be set to "file" to explicitly save a file container instead of an image.

PDF Password support (new in Scribe 2.0), pass a "password" parameter to password-protect the saved PDF. You can optionally specify separate "userPassword" and "ownerPassword" parameters. For example, if you've done a find and replace operation on a Word document and would like to store it into a container field called 'ResultContainer' while retaining the original filename, you would do it this way: Set Field[ ResultContainer; ScribeDocSaveContainer("") ]

Parameters:
Returns: A container field value which can be inserted into any container field with a Set Field script step.

ScribeDocSaveFile ( path {; flatten=true } )

Saves the currently loaded file to disk, applying any modifications. This closes the document after saving it.

The path parameter tells Scribe where to save the file to. This can take several forms:

  • It can be empty, like this: ScribeDocSaveFile(""). That tells Scribe to save the modified file into a temporary directory, keeping the original filename.
  • It can be just a filename, like this: ScribeDocSaveFile("MyNewFile.doc"). That tells Scribe to save the modified file into a temporary directory, with a new filename.
  • It can be just a directory, like this: ScribeDocSaveFile( Get (DesktopPath) ). That tells Scribe to save the modified file into the specified directory, keeping the original filename.
  • It can be a full path with a filename, like this: ScribeDocSaveFile( Get(DesktopPath) & "MyNewFile.doc" ). That tells Scribe to save the modified file into the specified directory with a new filename.

The optional flatten parameter can be used with PDF forms to save a "flattened" version of the form, this would make the form fields unenterable.

PDF Password support (new in Scribe 2.0), pass a "password" parameter to password-protect the saved PDF. You can optionally specify separate "userPassword" and "ownerPassword" parameters.

Parameters:
Returns: FileMaker file path to the saved file, for example 'file:/Macintosh HD/Users/jesse/Desktop/Letter_to_clients.docx'. This can be used with the 'Insert File' script step to insert the file into a container field in FileMaker.

ScribeFileAsKeywords ( fileOrContainer )

Returns a unique list of keywords for the file. Unlike ScribeFileAsText, this only returns unique names, and strips out common "stop words" like "a", "and", "the", etc. This can reduce storage requirements if you are performing text searches against the contents of files, but don't need the extracted text to be human-readable.

Parameters:
file
file or container field to extract index from
See also: ScribeFileAsText
Returns: A unique list of keywords in the currently loaded document, or "ERROR" if an error occurs.

ScribeFileAsText ( fileOrContainer{; param1=value1; param2=value2} )

Returns the plain text content of the file.

For binary file document formats such as Word, PDF, etc. this attempts to return a human-readable presentation of the document. XML documents are returned as-is. Any unrecognized file will have its raw text contents returned (see optional parameters to customize this).

You can pass in optional additional parameters to customize the behavior of this function. A list of customizations follows:

  • onlyKnownTypes=0 or 1. If this is set to 1, then Scribe will return an empty value "" for unknown file types, instead of returning their raw contents. The default is 0.

Here is a list of supported file types for reading text from:

  • pdf
  • doc, docx
  • xls, xlsx
  • ppt, pptx
  • xml, xsd
  • rtf
  • htm, html
  • JPEG (will read EXIF metadata)
  • csv, txt, tab
  • msg (Outlook emails)
  • pages, key (Apple's Pages and Keynote documents '08 & '09)
Parameters:
file
file or container field to extract text from
Returns: plain text content of the currently loaded document, or an empty string if the input is empty, or "ERROR" if an error occurs.

ScribeHighlight ( text; highlightPattern {; param1=value1 ; param2=value2 ; ...} )

Highlights all occurrences of highlightPattern in text.

Unlike the substitute function, this is case-insensitive by default. The highlightPattern function supports regular expression patterns.

Regular Expression Pattern Processing

Using the flags optional parameter, you may set the following options, each of which influences the way patterns are matched.

caseInsensitive
Enables case-insensitive matching for US-ASCII characters.
multiline
Does not match line-terminating characters. This means that when the input text is a return-separated list, each line is matched independently.
literal
Treats metacharacters like ^ and $ and escape sequences like \t as literals.
includeLineEndings
Matches line-terminating characters, which means that a return-separated list would be treated as a single text block.
ignoreWhitespace
Ignores whitespace characters.

Example

Example of a highlight operation to match the string "file://" at the beginning of each line of a return-separated list.

Set Field [ Globals::highlighted_text =
    ScribeHighlight(
    "file://temp/doc.txt" & ¶ &
    "file://documents/doc.txt" & ¶ &
    "http://my.site.com/home" & ¶ &
    "ftp://my.ftpsite.com/upload" ;
        "^file://" ;
        "flags=multiline"
    )
]

This matches "file://temp/doc.txt" & ¶ & "file://documents/doc.txt"

Style, color and size

Highlighting style is determined by the three optional parameters: colorRGB, styles, and size. Consult the Filemaker TextStyleAdd and TextColor documentation for more details about named Filemaker text styles and colors.

Example

Example of a highlight operation to make any occurrences of "atlanta" blue and bold (the default highlight style is bold, blue text):

Set Field [ Globals::highlighted_text =
    ScribeHighlight(Documents::body ; "atlanta")
]

Example of a highlight operation to highlight runs of 1 or more sequential numbers as green italic text:

Set Field [ Globals::highlighted_text =
    ScribeHighlight(
        Documents::body ;
        "[0-9]+" ;
        "colorRGB=" & RGB(0;255;0) ;
        "styles=" + Italic"
    )
]


Parameters:
text
The input text
highlightPattern
the word or regular expression pattern to highlight
additionalParameters
Additional parameters are specified using a name=value syntax. The parameters colorRGB, size and styles control the look of the replaced text. The parameter flags controls the way in which pattern matching is performed.
Returns: The input text with all occurrences of highlightPattern highlighted with the current styles.

ScribeLastError

Returns the last Scribe-related error which occurred. This should be called any time that a plugin function returns "ERROR" to get a user-readable description of the error.

Returns: Error text, or "" if there was no error.

ScribeLicenseInfo

Returns information about the license used.


ScribePatternMatchAll ( text; regex {; flags=flag1+flag2+flag3+...} )

Returns a newline-delimited list containing pattern matches. Any text that is not a pattern match will be omitted.

Example of a function to extract a return-separated list of numbers from a string.

ScribePatternMatchAll("123 and 5321 are open, but 0121 is closed" ; "[0-9]+")
/* returns the following:
123
5321
0121
*/


Regular Expression Pattern Processing

Using the flags optional parameter, you may set the following options, each of which influences the way patterns are matched.

caseInsensitive
Enables case-insensitive matching for US-ASCII characters.
multiline
Does not match line-terminating characters. This means that when the input text is a return-separated list, each line is matched independently.
literal
Treats metacharacters like ^ and $ and escape sequences like \t as literals.
includeLineEndings
Matches line-terminating characters, which means that a return-separated list would be treated as a single text block.
ignoreWhitespace
Ignores whitespace characters.

The default behavior of this function uses the caseInsensitive and includeLineEndings flags, so the following function calls are equivalent:


ScribePatternMatchAll(
    "Wilhelm¶wilson¶Williams¶Zander" ;
    "wil.*" ;
    "flags=includeLineEndings+caseInsensitive"
)
ScribePatternMatchAll(
    "Wilhelm¶wilson¶Williams¶Zander" ;
    "wil.*"
)


Parameters:
text
input text
regex
regular expression pattern.
flags
An additional parameter used to specify flags that control how pattern matching is performed. To specify multiple flags, separate each with a plus sign (e.g., ..."flags=literal+ignoreWhitespace")
Returns: Any pattern matches, separated by line breaks.

ScribePatternReplaceAll ( text; regex; replacement {; param1=value1 ; param2=value2 ; ...} )

Replace all occurrences of a regex pattern with some replacement text. The replacement text can optionally be styled.

Highlighting style is determined by the three optional parameters: colorRGB, styles, and size. Consult the FileMaker TextStyleAdd and TextColor documentation for more details about named Filemaker text styles and colors.

Backreferences can also be used with the regular expression. Replacement text can use dollar sign syntax ($1, $2, etc.) to refer to these groups.

Regular Expression Pattern Processing

Using the flags optional parameter, you may set the following options, each of which influences the way patterns are matched.

caseInsensitive
Enables case-insensitive matching for US-ASCII characters.
multiline
Does not match line-terminating characters. This means that when the input text is a return-separated list, each line is matched independently.
literal
Treats metacharacters like ^ and $ and escape sequences like \t as literals.
includeLineEndings
Matches line-terminating characters, which means that a return-separated list would be treated as a single text block.
ignoreWhitespace
Ignores whitespace characters.


Example of simple replace, converting two or more consecutive line breaks to a single line break:


ScribePatternReplaceAll(
    "Line one¶Line Two¶¶¶Line Three¶Line Four" ;
    "\n+" ;
    "¶"
)
// returns "Line one¶Line Two¶Line Three¶Line Four"


Example of a highlighting replace operation, highlighting the literal string "quick" by using styles:


ScribePatternReplaceAll("The quick brown fox" ;
    "quick" ;
    "quick" ;
    "colorRGB=" & RGB(128 ; 128 ; 255) ;
    "styles=" + Bold
)
// returns The quick brown fox


Parameters:
text
The input text
regex
The regular expression
replacement
The text to replace the found occurrences with
additionalParameters
Additional parameters are specified using a name=value syntax. The parameters colorRGB, size and styles control the look of the replaced text. The parameter flags controls the way in which pattern matching is performed.
See also: ScribeHighlight
Returns: The input text with all occurrences of regex replaced with replacement

ScribeVersion

Returns the version of the plugin which is installed.