Jump to content

Text file parameters


topten
 Share

Recommended Posts

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If to be more precise in consolewrite I am geting such things

"7"="asdasdasdasdasdasdasdasdasdasd"          
"8"="sdftrtytyiyuiyjghnfghfghrtyrgdfsdfw
asdasdasd"            asdasdasdasdasertertertrthgbgfgdf
"9"="qweasdxcvdfgrtyfghvbnghryfgbcv"

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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