Jump to content
Sign in to follow this  

FileWrite script line

Recommended Posts


I want to use an Inputbox to write a line that i will later use with Java/Indesign:

The problem line keeps getting me errors, what am i doing wrong?

$PR = InputBox("PR", "Enter the 1 or 2 character code.")


Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = @TempDir & "\FileWrite.txt"

    ; Open the file for writing (append to the end of a file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False

    ; Write data to the file using the handle returned by FileOpen.
    FileWrite($hFileOpen,"text  {findWhat:"#PR"}    {changeTo:" & $PR & "}  {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false}" & @CRLF)
    FileWrite($hFileOpen, $TEST & @CRLF)

    ; Close the handle returned by FileOpen.

The problem line is:

    FileWrite($hFileOpen,"text    {findWhat:"#PR"}    {changeTo:" & $PR & "}    {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false}" & @CRLF)


Share this post

Link to post
Share on other sites

If you have double quotes in your string, you should encase them in single quotes.

FileWrite($hFileOpen,'text  {findWhat:"#PR"}    {changeTo:" & $PR & "}  {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false}' & @CRLF)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...