Jump to content

80 Character Fixed Length Help


Recommended Posts

hello i have to build a script that will take some text files that the text on each line is roughly 1-4096 characters in width. i need to remove the CRLF's and convert the text to 80 characters wide, can anyone point me to some sample scripts or what function in autoit i would use?

thanks

James

Edited by KeeWay
Link to comment
Share on other sites

So basically what you're wanting to do is read in a text file, strip all new line characters, and then make the document have new lines at 80 characters?

You would need to do this yourself. If you could turn it into a function of some sort, then maybe release that for public use and comments in the Example Scripts forum. You could also search there to see if someone has already done something similar.

Some functions you may want to look at:

FileOpen()
FileRead()
FileClose()
StringReplace()
FileWrite()
FileWriteLine()?

Those are just the basic ones I can think of off the top of my head that you may want to look into to help you with this project. However, I don't believe there is any completed code doing exactly what you're wanting, but it shouldn't be hard to create such a script.

I hope this helps,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

=)

MsgBox(0, "", _StringBlock("HAHAHAAAAAAAAA" & @CRLF & "This is funny", 4))


Func _StringBlock($sString, $iWide)
    Local $ReturnString
    $sString = StringRegExpReplace($sString, @CRLF, "")
    $sString = StringRegExpReplace($sString, @CR, "")
    $Repeats = Floor(StringLen($sString) / $iWide)
    For $I = 0 To $Repeats
        $ReturnString &= StringLeft($sString, $iWide) & @CRLF
        $sString = StringTrimLeft($sString, $iWide)
    Next
    Return $ReturnString
EndFunc
Link to comment
Share on other sites

=)

MsgBox(0, "", _StringBlock("HAHAHAAAAAAAAA" & @CRLF & "This is funny", 4))


Func _StringBlock($sString, $iWide)
    Local $ReturnString
    $sString = StringRegExpReplace($sString, @CRLF, "")
    $sString = StringRegExpReplace($sString, @CR, "")
    $Repeats = Floor(StringLen($sString) / $iWide)
    For $I = 0 To $Repeats
        $ReturnString &= StringLeft($sString, $iWide) & @CRLF
        $sString = StringTrimLeft($sString, $iWide)
    Next
    Return $ReturnString
EndFunc

wow thanks for that, this worked out perfect >_< ...

i am still new to this and was looking at the help using the fileread function but this is so much better/cleaner.. i have a lot to learn.

thanks

James

Link to comment
Share on other sites

wow thanks for that, this worked out perfect >_< ...

i am still new to this and was looking at the help using the fileread function but this is so much better/cleaner.. i have a lot to learn.

thanks

James

James,

Continuing to work with FileRead() so you can get the text to send that function is crucial, but he certainly did a decent job of getting you some working code. I hope you are able to learn a lot from it! GL with AutoIt!

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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