skippynz Posted January 15, 2006 Share Posted January 15, 2006 (edited) the idea is to create a webpage based on the jpg files you tell it too use. the problem im having is where it seems to only create 1 webpage and thats the last file in the array. but when i put a message box at the end of the filewriteline's its going through each of the array variables like it should. why doesnt it create all webpages - ie if you select 5 files only the last gets created.... this is soooo fustrating. heres my code #include <Array.au3> #include <file.au3> FileDelete("test.txt") $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, @MyDocumentsDir , "JPG Images (*.jpg)", 4 ) Dim $test If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) $var = StringReplace($var, ".jpg","") FileWrite ( "test.txt", $var ) _FileReadToArray("test.txt", $test) _ArrayDisplay( $test, "Results of the array" ) EndIf For $x = 2 To $test[0] FileOpen ( $test[$x] & ".htm", 2 ) FileWriteLine( $test[$x] & ".htm" , '<html>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<head>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</head>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<body>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<div align="center"><table width="100%" height ="100%" border="1" cellspacing="0" cellpadding="0">' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<tr><td><img src="' & $test[$x] & '.jpg"></td></tr>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</table></div>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</body>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</html>' & @CRLF) Next thanks for your help in advance.....PS AUTOIT is the BOMB Edited January 15, 2006 by craig.gill Link to comment Share on other sites More sharing options...
ChrisL Posted January 15, 2006 Share Posted January 15, 2006 (edited) the idea is to create a webpage based on the jpg files you tell it too use. the problem im having is where it seems to only create 1 webpage and thats the last file in the array. but when i put a message box at the end of the filewriteline's its going through each of the array variables like it should. why doesnt it create all webpages - ie if you select 5 files only the last gets created.... this is soooo fustrating. heres my code #include <Array.au3> #include <file.au3> FileDelete("test.txt") $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, @MyDocumentsDir , "JPG Images (*.jpg)", 4 ) Dim $test If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) $var = StringReplace($var, ".jpg","") FileWrite ( "test.txt", $var ) _FileReadToArray("test.txt", $test) _ArrayDisplay( $test, "Results of the array" ) EndIf For $x = 2 To $test[0] FileOpen ( $test[$x] & ".htm", 2 ) FileWriteLine( $test[$x] & ".htm" , '<html>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<head>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</head>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<body>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<div align="center"><table width="100%" height ="100%" border="1" cellspacing="0" cellpadding="0">' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '<tr><td><img src="' & $test[$x] & '.jpg"></td></tr>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</table></div>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</body>' & @CRLF) FileWriteLine( $test[$x] & ".htm" , '</html>' & @CRLF) Next thanks for your help in advance.....PS AUTOIT is the BOMB Move your file open to before the for loop, I think its wiping it every time Edit... is it supposed to create a new file for each image is that what your doing? Edited January 15, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
skippynz Posted January 15, 2006 Author Share Posted January 15, 2006 Move your file open to before the for loop, I think its wiping it every timeEdit... is it supposed to create a new file for each image is that what your doing?I tried it without the file open, makes no difference - i was just trying that to see if it would resolve my issue but it didnt.with each file having a different name it should have pulled the name and used that for the HTML file name. ie if you select the jpg files "background12.jpg" and "background13.jpg" the script strips out the .jpg and should create 2 files, one called "background12.htm" and the other should be called "background13.jpg" Link to comment Share on other sites More sharing options...
ChrisL Posted January 15, 2006 Share Posted January 15, 2006 I think this works #include <Array.au3> #include <file.au3> FileDelete("test.txt") $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, @MyDocumentsDir , "JPG Images (*.jpg)", 4 ) Dim $test If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) $var = StringReplace($var, ".jpg","") FileWrite ( "test.txt", $var ) _FileReadToArray("test.txt", $test) _ArrayDisplay( $test, "Results of the array" ) EndIf For $x = 2 To $test[0] $file = FileOpen ( $test[$x] & ".htm", 2 ) FileWriteLine( $file , '<html>' & @CRLF) FileWriteLine( $file, '<head>' & @CRLF) FileWriteLine( $file , '</head>' & @CRLF) FileWriteLine( $file , '<body>' & @CRLF) FileWriteLine( $file , '<div align="center"><table width="100%" height ="100%" border="1" cellspacing="0" cellpadding="0">' & @CRLF) FileWriteLine( $file , '<tr><td><img src="' & $test[$x] & '.jpg"></td></tr>' & @CRLF) FileWriteLine( $file , '</table></div>' & @CRLF) FileWriteLine( $file , '</body>' & @CRLF) FileWriteLine( $file , '</html>' & @CRLF) FileClose ($File) Next [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
skippynz Posted January 15, 2006 Author Share Posted January 15, 2006 I think this worksi just tried but now i get this error messageNew AutoIt v3 Script (2).au3 (35) : ==> Invalid file handle used.: FileWriteLine( $file , '<html>' & @CRLF) Link to comment Share on other sites More sharing options...
Oxin8 Posted January 15, 2006 Share Posted January 15, 2006 if i'm understanding this right... you're just using the txt file to get them in any array. use StringSplit, it's much easier. I went ahead and tidied up your code and tested it. Works fine for me. $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, @MyDocumentsDir , "JPG Images (*.jpg)", 4 ) Dim $test If @error Then MsgBox(4096,"","No File(s) chosen") Else $test = StringSplit($var, "|") EndIf For $x = 2 To $test[0] $myfile = FileOpen ( StringReplace($test[$x],".jpg","") & ".htm", 2 ) FileWriteLine( $myfile , '<html>') FileWriteLine( $myfile, '<head>') FileWriteLine( $myfile, '</head>') FileWriteLine( $myfile , '<body>') FileWriteLine( $myfile , '<div align="center"><table width="100%" height ="100%" border="1" cellspacing="0" cellpadding="0">') FileWriteLine( $myfile , '<tr><td><img src="' & $test[$x] & '"></td></tr>') FileWriteLine( $myfile , '</table></div>') FileWriteLine( $myfile , '</body>') FileWriteLine( $myfile , '</html>') Next ~My Scripts~ *********_XInput UDF for Xbox 360 ControllerSprayPaint_MouseMovePlus Link to comment Share on other sites More sharing options...
ChrisL Posted January 15, 2006 Share Posted January 15, 2006 (edited) i just tried but now i get this error messageNew AutoIt v3 Script (2).au3 (35) : ==> Invalid file handle used.: FileWriteLine( $file , '<html>' & @CRLF)It works perfectly on mine.. using the beta build thoughEdit* works on the release build as well Edited January 15, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
skippynz Posted January 15, 2006 Author Share Posted January 15, 2006 if i'm understanding this right... you're just using the txt file to get them in any array. use StringSplit, it's much easier. I went ahead and tidied up your code and tested it. Works fine for me. $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, @MyDocumentsDir , "JPG Images (*.jpg)", 4 ) Dim $test If @error Then MsgBox(4096,"","No File(s) chosen") Else $test = StringSplit($var, "|") EndIf For $x = 2 To $test[0] $myfile = FileOpen ( StringReplace($test[$x],".jpg","") & ".htm", 2 ) FileWriteLine( $myfile , '<html>') FileWriteLine( $myfile, '<head>') FileWriteLine( $myfile, '</head>') FileWriteLine( $myfile , '<body>') FileWriteLine( $myfile , '<div align="center"><table width="100%" height ="100%" border="1" cellspacing="0" cellpadding="0">') FileWriteLine( $myfile , '<tr><td><img src="' & $test[$x] & '"></td></tr>') FileWriteLine( $myfile , '</table></div>') FileWriteLine( $myfile , '</body>') FileWriteLine( $myfile , '</html>') Next this works a treat thanks for your help guys. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now