Sign in to follow this  
Followers 0
blaat34

FileWrite script line

6 posts in this topic

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)

 

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)

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

thanks man, only my $PR input doesn't work, is there anyway i could make that work?

Share this post


Link to post
Share on other sites

ha, sorry man thanks for helping out.

actually i found a solution!

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  
Followers 0