Skip to content

Instantly share code, notes, and snippets.

@petrowsky
Created February 12, 2015 05:13
Show Gist options
  • Save petrowsky/2089f07e7a49a53e8fee to your computer and use it in GitHub Desktop.
Save petrowsky/2089f07e7a49a53e8fee to your computer and use it in GitHub Desktop.
PythonWrapText Custom Function - FileMaker
/*
* PythonWrapText ( text ; columns ; prefix )
*
* A bBox plugin function for wrapping text.
* http://www.beezwax.net/download/bbox
*
*/
Let ( [
~script = List (
"import textwrap" ;
"list = textwrap.wrap(content, width=" & columns & ")" ;
"for element in list:" ;
" print '" & prefix & "' + element"
);
~compiled = bBox_PythonCompile( 0 ; ~script );
~data = bBox_PythonSetVar( "content" ; text ; "s" );
~result = bBox_PythonExecute( ~script );
~hasError = ~result = "?"
];
Case (
Evaluate ( "bBox_Version( \"\" )" ) = "?";
"bBox plug-in missing";
~hasError;
bBox_PythonFinalize & "Error";
~result
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment