topten Posted February 20, 2016 Share Posted February 20, 2016 Is it possible to set the text file parameters? For example in notepad.txt I can manually set the patameters of page for printing 420x594 mm. How to do it programmatically Link to comment Share on other sites More sharing options...
water Posted February 20, 2016 Share Posted February 20, 2016 What have you tried so far? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 Thank you, water for your response. The thing is I am reading a text file line by line , encoding it base64 and then writing it to another text file. So in the text file it is supposed to be something like "1"="asdfghasdfghasdfghasdfghasdfghasdfgahsdfghasd" "2"="asdghjasdghajsdhgajsdhgasdjhgasdjhgasdjhgasdjhgasdjhg" etc But as a result I am getting the situation when a very long line is broken into 2 or 3 lines and I am getting "1"="asdfghasdfghasd fghasdfghasdfghasdfgahsdfghasd" "2"="asdghjasdghajsdhgajsdhgasdjhgasdjhga sdjhgasdjhgasdjhg" etc The code is $sFilePath = @DesktopDir & "outfile.txt" $num = _FileCountLines ( $sFilePath ) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) for $i = 1 to $num Local $sFileRead = FileReadLine($hFileOpen, $i) ConsoleWrite ($sFileRead & @CRLF) $base64encoded = _Base64Encode ($sFileRead, False) filewrite (@DesktopDir & "\infile.txt", '"'&$i & '"="' & $base64encoded & '"' & @CRLF) next I think, may be this line breaking is happening, because the width of txt file innitially set? Link to comment Share on other sites More sharing options...
water Posted February 20, 2016 Share Posted February 20, 2016 You mean: Even with ConsoleWrite you get 2 or 3 lines which are shorter than the maximum width of the SciTE output pane? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 Yes, right Sometimes I am getting in 3 lines, something like "1"="asdfgha sdfghasdfghasdfghasdfgh asdfgahsdfghasd" Instead of "1"="asdfghasdfghasdfghasdfghasdfghasdfgahsdfghasd" Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 If to be more precise in consolewrite I am geting such things "7"="asdasdasdasdasdasdasdasdasdasd" "8"="sdftrtytyiyuiyjghnfghfghrtyrgdfsdfwasdasdasd" asdasdasdasdasertertertrthgbgfgdf "9"="qweasdxcvdfgrtyfghvbnghryfgbcv" Link to comment Share on other sites More sharing options...
water Posted February 20, 2016 Share Posted February 20, 2016 According to wikipedia there seems to be a maximum line length of 76 bytes for mime before a CRLF is being inserted. https://en.wikipedia.org/wiki/Base64#MIME My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 I see. What I am doing now - I am writing these into txt file and then manually change the "linebreaks on/off" parameter in notepad. When I manually changes this then all lines are going without breaks. I wonder, Can I do anything about that programmatically Link to comment Share on other sites More sharing options...
water Posted February 20, 2016 Share Posted February 20, 2016 I'm not sure it is sensible to have your script and the base64 encoding function insert CRLF into the result. I think you should read the while file using FileRead (ignoring CRLF), encode it and then write the result to the output file without adding a CRLF. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 That's the problem. The file should have the structure "1"="...................." "2"="...................." etc If it gets the structure like a "1"="..................................... .................... ......" "2"=".......................... ............ ...." It will fail. It is a .reg file Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 I tried to remove @CRLF- after that everythin is becoming even more messy Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 But what is interesting. $hFileOpen2 = @DesktopDir & "\patchcreating\in.txt" $hFileOpen3 = @DesktopDir & "\patchcreating\out.txt" $sFileRead = FileReadLine($hFileOpen2, 1) $sFileRead2 = FileReadLine($hFileOpen2, 2) FileWriteLine($hFileOpen3, $sFileRead& $sFileRead2) When I read the ready file's line 1 and line 2 and then write them together into another file they are written into one line as it is supposed Link to comment Share on other sites More sharing options...
water Posted February 20, 2016 Share Posted February 20, 2016 That's what I said: Looks like the encoding routine inserts the CRLF. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 I have designed quite a hackish way to fix it though $source = FileRead (@DesktopDir & "in.txt") $text = StringRegExp($source, '(?s)="(.*?)"', 3) for $i = 0 to UBound ($text)-1 $string = StringStripWS($text[$i],8) filewrite (@DesktopDir & "\out.txt", '"'&$i+1 & '"="' & $string & '"' & @CRLF) next Have to create another file and after that remove those whitespaces. Works, but still not solved, why can't I just directly write into innitial file without those line breaks Link to comment Share on other sites More sharing options...
topten Posted February 20, 2016 Author Share Posted February 20, 2016 You are right, Water. It is the encoding routine, that is inserting CRLF, I found it in the udf 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