Jump to content

Help with Notepad Script


Guest DaveAvery
 Share

Recommended Posts

Guest DaveAvery

I am trying to write a script that will insert a carriage return or go to the next line after 80 characters including spaces. The problem is my script gets stuck in the loop and will lock up my entire computer. I have posted some of the code below for help. Thanks

$thefile = InputBox("File","Enter File Name"); gets input file name and path from user

$input = FileOpen($thefile,0);opens specified file

$output = FileOpen(StringLeft($input,StringLen($input) - 4) & "o" & StringRight($input,4),1);opens output file, same file name with an 'O' added before the extension

if $input = -1 Then;error handling for file open

MsgBox(0,"Oops","Failed to open the file")

Exit

EndIf

while 1;loop until we stop it

$line = FileRead($input,80);grab80 characters

if $line = -1 then ExitLoop;stop loop if end of file

Send("{Enter}");writes 80 characters to a line in output file and goes to next line

WEnd

FileClose($input);close files

Link to comment
Share on other sites

$thefile = InputBox("File", "Enter File Name"); gets input file name and path from user

$input = FileOpen($thefile, 0);opens specified file

$output = FileOpen(StringLeft($thefile, StringLen($thefile) - 4) & "o" & StringRight($thefile, 4), 1);opens output file, same file name with an 'O' added before the extension
If $input = -1 Then;error handling for file open
    MsgBox(0, "Oops", "Failed to open the file")
    Exit
EndIf
While 1;loop until we stop it
    $line = FileRead($input, 80);grab80 characters
    If @error Then ExitLoop;stop loop if end of file
    FileWriteLine($output,$line)
;~  Send("{Enter}");writes 80 characters to a line in output file and goes to next line
WEnd
FileClose($input);close files
FileClose($output);close files

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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