Jump to content

FileWrite script line


Recommended Posts

Hi,

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.")


Example()

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
    EndIf

    ; 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.
    FileClose($hFileOpen)

The problem line is:

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

 

Link to comment
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)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...