Jump to content

_GUICtrlEdit_SetText 50/50


Casey
 Share

Recommended Posts

Hello,

I believe I am stumbling a bit somewhere between GUICtrlCreateEdit and _GUICtrlEdit_SetText in the attached code. Try as I might I am missing something that I can't put my finger on so I am looking for a keen pair of eyes.

I am documenting a site and I am making use of PmWiki. I wanted to make it easier for some of the folks to document some of the scripts that are in place. The intent of the code is to allow me to browse for a text file, pull its contents into the GUI, edit it with some WIKI markup, and then output the modified version to a new file. The code below stops short of any output function because I noticed the problem part way through creating the buttons.

The problem I am encountering is that when some files are read I can only cut or delete text from within the edit box. Others behave as I wish them to and allow for the buttons to enter text. Much of the code is borrowed from the help file and I am very greatful for it. Thank you.

Any insight as to why this might be happening would be appreciated.

OS: Vista Ent. SP2

Autoit: v3.2.13.13(beta) and v3.3.0.0 are installed.

EDIT 01JUN2011: Altered original code that was posted to include the fix.

#include <Date.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>



Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 0)
$Debug_Ed = False

Global $StatusBar, $hEdit, $hGUI, $MakeItHappen
Global $msg, $var4, $var5, $var6, $var7, $var9, $oFile, $aCharPos
Global $message = "Browse for the file you wish to alter."
Global $black, $blue, $burnttorange, $green, $red, $white
Global $BeginBlockWikiMarkup, $EndBlockWikiMarkup, $blankLineBlockWikiMarkup, $LongSeperatorBlockWikiMarkup, $BeginMakeBig, $EndMakeBig
Global $Space1, $Space2, $Space3, $Space4, $Space5, $Space6, $BeginBlockWikiMarkupReformat, $EndBlockWikiMarkupReformat, $blankLineBlockWikiMarkupAddComment
Global $list1, $list2, $list3, $list4, $Italics, $Bold, $BoldItalics
Global $Head1, $Head2, $Head3, $Head4, $Head5, $Head6
Global $SAVE, $SaveLocation = @ScriptDir
Global $FileNameArray, $FileNameArrayLocation, $NameFile
Global $SelectAll,$dll = DllOpen("user32.dll")

Global $aParts[6] = [100, 300, 500, 700, 900, 1100];,$aPartRightSide[2] = [378, -1],
Global $sFile
$sFile = FileOpenDialog($message, @ScriptDir & "\", "Text files (*.txt)")

$FileNameArray = StringSplit($sFile, "\")
$FileNameArrayLocation = UBound($FileNameArray) - 1
$NameFile = $FileNameArray[$FileNameArrayLocation]
$NameFile = StringReplace($NameFile, ".txt", "", 0)

; Create GUI
$hGUI = GUICreate("PMWIKI Markup Studio UNO", 1400, 800)
GUISetStyle(0x00CF0000)
GUISetIcon(@SystemDir & "\drwatson.exe", 0)
GUISetState() ;Show GUI



$hEdit = GUICtrlCreateEdit("", 2, 2, 1394, 468, BitOR($ES_WANTRETURN, $WS_VSCROLL))
; Set Margins
_GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)
;Set text limit
_GUICtrlEdit_SetLimitText($hEdit, 200000)
; Set Text
_GUICtrlEdit_SetText($hEdit, FileRead($sFile))

$StatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
_GUICtrlStatusBar_SetIcon($StatusBar, 0, 97, "shell32.dll")
_GUICtrlStatusBar_SetText($StatusBar, "Unicode format : " & _GUICtrlStatusBar_GetUnicodeFormat($StatusBar), 1)
_GUICtrlStatusBar_SetText($StatusBar, "Current Lines: " & _GUICtrlEdit_GetLineCount($hEdit), 2)
_GUICtrlStatusBar_SetText($StatusBar, "Text Limit: " & _GUICtrlEdit_GetLimitText($hEdit), 3)
_GUICtrlStatusBar_SetText($StatusBar, "Current Text: " & _GUICtrlEdit_GetTextLen($hEdit), 4)
_GUICtrlStatusBar_SetText($StatusBar, "Output will be saved to: " & @ScriptDir, 5)

GUISetState()

$black = GUICtrlCreateButton("% black %", 2, 480, 180, 30)
$blue = GUICtrlCreateButton("% blue %", 2, 520, 180, 30)
$burnttorange = GUICtrlCreateButton("% burnttorange %", 2, 560, 180, 30)
$green = GUICtrlCreateButton("% green %", 2, 600, 180, 30)
$red = GUICtrlCreateButton("% red %", 2, 640, 180, 30)
$white = GUICtrlCreateButton("% white %", 2, 680, 180, 30)


$BeginBlockWikiMarkup = GUICtrlCreateButton("No Mark [@ ", 192, 480, 180, 30)
$EndBlockWikiMarkup = GUICtrlCreateButton("No Mark @]\\ ", 192, 520, 180, 30)
$blankLineBlockWikiMarkup = GUICtrlCreateButton("No Mark Blank Line [@@]\\ ", 192, 560, 180, 30)
$blankLineBlockWikiMarkupAddComment = GUICtrlCreateButton("No Mark Blank Line Cmnt [@#@]\\ ", 192, 600, 180, 30)
$LongSeperatorBlockWikiMarkup = GUICtrlCreateButton(" [@########@]\\ ", 192, 640, 180, 30)
$BeginBlockWikiMarkupReformat = GUICtrlCreateButton("No Mark Reformat [= ", 192, 680, 180, 30)
$EndBlockWikiMarkupReformat = GUICtrlCreateButton("No Mark Reformat =] ", 192, 720, 180, 30)


$Space1 = GUICtrlCreateButton("1 -> ", 382, 480, 180, 30)
$Space2 = GUICtrlCreateButton("2 --> ", 382, 520, 180, 30)
$Space3 = GUICtrlCreateButton("3 ---> ", 382, 560, 180, 30)
$Space4 = GUICtrlCreateButton("4 ----> ", 382, 600, 180, 30)
$Space5 = GUICtrlCreateButton("5 ----->", 382, 640, 180, 30)
$Space6 = GUICtrlCreateButton("6 ------> ", 382, 680, 180, 30)

$list1 = GUICtrlCreateButton("Bullet * ", 572, 480, 180, 30)
$list2 = GUICtrlCreateButton("Bullet Sub **", 572, 520, 180, 30)
$list3 = GUICtrlCreateButton("Number # ", 572, 560, 180, 30)
$list4 = GUICtrlCreateButton("Number Sub ## ", 572, 600, 180, 30)

$Head1 = GUICtrlCreateButton("Maj Subheading !! ", 762, 480, 180, 30)
$Head2 = GUICtrlCreateButton("Minor Subheading !!!", 762, 520, 180, 30)
$Head3 = GUICtrlCreateButton("nore Subheading !!!!", 762, 560, 180, 30)
$Head4 = GUICtrlCreateButton("Subheadings !!!!!", 762, 600, 180, 30)
$Head5 = GUICtrlCreateButton("Horiz. Line  ----", 762, 640, 180, 30)
$Head6 = GUICtrlCreateButton("Table || ", 762, 680, 180, 30)

$Italics = GUICtrlCreateButton("Italics ''", 952, 480, 180, 30)
$Bold = GUICtrlCreateButton("Bold '''", 952, 520, 180, 30)
$BoldItalics = GUICtrlCreateButton("Bold Italics '''''", 952, 560, 180, 30)
$BeginMakeBig = GUICtrlCreateButton("Make Big [+ ", 952, 600, 180, 30)
$EndMakeBig = GUICtrlCreateButton("Make Big +] ", 952, 640, 180, 30)

$SAVE = GUICtrlCreateButton("Save Modifications to File", 1230, 730, 180, 30)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            _save()
            MsgBox(0, "", "Any saved modifications can be found in a new file that was created in the same directory from which this program was run.")
            DllClose($dll)
            ExitLoop
        Case $msg = _IsPressed("11", $dll) And _IsPressed("41", $dll)   
            $SelectAll=_GUICtrlEdit_SetSel($hEdit, 0, -1)
        Case $msg = $black
            ClipPut("%black%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $blue
            ClipPut("%blue%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $burnttorange
            ClipPut("%burnttorange%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $green
            ClipPut("%green%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $red
            ClipPut("%red%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $white
            ClipPut("%white%")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $BeginBlockWikiMarkup
            ClipPut("[@")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $EndBlockWikiMarkup
            ClipPut("@]\\")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $blankLineBlockWikiMarkup
            ClipPut("[@@]\\")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $blankLineBlockWikiMarkupAddComment
            ClipPut("[@#@]\\")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $LongSeperatorBlockWikiMarkup
            ClipPut("[@##############################################################################################################@]\\")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $BeginBlockWikiMarkupReformat
            ClipPut("[=")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $EndBlockWikiMarkupReformat
            ClipPut("=]")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $BeginMakeBig
            ClipPut("[+")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $EndMakeBig
            ClipPut("+]")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space1
            ClipPut("->")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space2
            ClipPut("-->")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space3
            ClipPut("--->")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space4
            ClipPut("---->")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space5
            ClipPut("----->")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Space6
            ClipPut("------>")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $list1
            ClipPut("*")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $list2
            ClipPut("**")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $list3
            ClipPut("#")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $list4
            ClipPut("##")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head1
            ClipPut("!!")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head2
            ClipPut("!!!")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head3
            ClipPut("!!!!")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head4
            ClipPut("!!!!!")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head5
            ClipPut("----")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Head6
            ClipPut("||")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Italics
            ClipPut("''")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $Bold
            ClipPut("'''")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $BoldItalics
            ClipPut("'''''")
            $var9 = _GUICtrlEdit_GetSel($hEdit)
            _GUICtrlEdit_InsertText($hEdit, ClipGet(), $var9[0])
            _update()
        Case $msg = $SAVE
            _save()
    EndSelect
WEnd

GUIDelete()

Func _save()
    $MakeItHappen = MsgBox(1, "", "Do you want to save your changes?")
    If $MakeItHappen == 1 Then
        $var4 = _NowTime(5)
        $var5 = StringReplace($var4, ":", "_", 0)
        $var6 = _NowDate()
        $var7 = StringReplace($var6, "/", "_", 0)
        $oFile = $SaveLocation & "\" & $NameFile & "_Modified_Output_" & $var7 & "_" & $var5 & ".txt" ;Check @script Dir
        FileOpen($oFile, 1)
        FileWrite($oFile, _GUICtrlEdit_GetText($hEdit))
        FileClose($oFile)
    EndIf
EndFunc   ;==>_save

Func _update()
    $var9 = ""
    _GUICtrlStatusBar_SetText($StatusBar, "Current Lines: " & _GUICtrlEdit_GetLineCount($hEdit), 2)
    _GUICtrlStatusBar_SetText($StatusBar, "Current Text: " & _GUICtrlEdit_GetTextLen($hEdit), 4)
    ControlFocus("PMWIKI Markup Studio UNO","","[CLASS:Edit;INSTANCE:1]")
EndFunc   ;==>_update
Edited by Casey
Link to comment
Share on other sites

A few things:

* Why are you using ClipPut and ClipGet like that?

* Your AutoIt installation is out of date, not to mention that the beta is older than the stable.

* Is there anything wrong with native functions?

Try this:

#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#RequireAdmin

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 0)
$Debug_Ed = False

Global $StatusBar, $hEdit, $hGUI,$MakeItHappen
Global $message = "Browse for the file you wish to alter."
Global $aPartRightSide[2] = [378, -1], $aCharPos, $var9, $black, $msg, $burnttorange, $green, $red, $white
Global $BeginBlockWikiMarkup, $EndBlockWikiMarkup, $blankLineBlockWikiMarkup, $LongSeperatorBlockWikiMarkup, $BeginMakeBig, $EndMakeBig, $MakeBold
Global $Space1, $Space2, $Space3, $Space4, $Space5, $Space6
Global $sFile
$sFile= FileOpenDialog($message, @ScriptDir & "\", "Text files (*.txt)")

; Create GUI
$hGUI = GUICreate("PMWIKI Markup Studio UNO", 1400, 800)
GUISetStyle(0x00CF0000)
GUISetIcon(@SystemDir & "\drwatson.exe", 0)
GUISetState() ;Show GUI

$hEdit = GUICtrlCreateEdit("", 2, 2, 1394, 468, BitOR($ES_WANTRETURN, $WS_VSCROLL))

$StatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
_GUICtrlStatusBar_SetIcon($StatusBar, 1, 97, "shell32.dll")
GUISetState()

; Set Margins
_GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

; Set Text
GUICtrlSetData($hEdit, FileRead($sFile), "")

$black = GUICtrlCreateButton("% black %", 2, 480, 150, 30)
$burnttorange = GUICtrlCreateButton("% burnttorange %", 2, 520, 150, 30)
$green = GUICtrlCreateButton("% green %", 2, 560, 150, 30)
$red = GUICtrlCreateButton("% red %", 2, 600, 150, 30)
$white = GUICtrlCreateButton("% white %", 2, 640, 150, 30)

$BeginBlockWikiMarkup = GUICtrlCreateButton(" [@ ", 162, 480, 150, 30)
$EndBlockWikiMarkup = GUICtrlCreateButton(" @]\\ ", 162, 520, 150, 30)
$blankLineBlockWikiMarkup = GUICtrlCreateButton(" [@@]\\ ", 162, 560, 150, 30)
$LongSeperatorBlockWikiMarkup = GUICtrlCreateButton(" [@########@]\\ ", 162, 600, 150, 30)
$BeginMakeBig = GUICtrlCreateButton(" [+", 162, 640, 150, 30)
$EndMakeBig = GUICtrlCreateButton(" +] ", 162, 680, 150, 30)
$MakeBold = GUICtrlCreateButton(" ''' ", 162, 720, 150, 30)

$Space1 = GUICtrlCreateButton("1 -> ", 322, 480, 150, 30)
$Space2 = GUICtrlCreateButton("2 --> ", 322, 520, 150, 30)
$Space3 = GUICtrlCreateButton("3 ---> ", 322, 560, 150, 30)
$Space4 = GUICtrlCreateButton("4 ----> ", 322, 600, 150, 30)
$Space5 = GUICtrlCreateButton("5 ----->", 322, 640, 150, 30)
$Space6 = GUICtrlCreateButton("6 ------> ", 322, 680, 150, 30)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $black
            GUICtrlSetData($hEdit, "%black%", 1)
        Case $msg = $burnttorange
            GUICtrlSetData($hEdit, "%$burnttorange%", 1)
        Case $msg = $green
            GUICtrlSetData($hEdit, "%green%", 1)
        Case $msg = $red
            GUICtrlSetData($hEdit, "%red%", 1)
        Case $msg = $white
            GUICtrlSetData($hEdit, "%white%", 1)
        Case $msg = $BeginBlockWikiMarkup
            GUICtrlSetData($hEdit, "[@", 1)
        Case $msg = $EndBlockWikiMarkup
            GUICtrlSetData($hEdit, "@]\\", 1)
        Case $msg = $blankLineBlockWikiMarkup
            GUICtrlSetData($hEdit, "[@@]\\", 1)
        Case $msg = $LongSeperatorBlockWikiMarkup
            GUICtrlSetData($hEdit, "[@##############################################################################################################@]\\", 1)
        Case $msg = $BeginMakeBig
            GUICtrlSetData($hEdit, "[+", 1)
        Case $msg = $EndMakeBig
            GUICtrlSetData($hEdit, "+]", 1)
        Case $msg = $MakeBold
            GUICtrlSetData($hEdit, "'''", 1)
        Case $msg = $Space1
            GUICtrlSetData($hEdit, "->", 1)
        Case $msg = $Space2
            GUICtrlSetData($hEdit, "-->", 1)
        Case $msg = $Space3
            GUICtrlSetData($hEdit, "--->", 1)
        Case $msg = $Space4
            GUICtrlSetData($hEdit, "---->", 1)
        Case $msg = $Space5
            GUICtrlSetData($hEdit, "----->", 1)
        Case $msg = $Space6
            GUICtrlSetData($hEdit, "------>", 1)
    EndSelect
WEnd

GUIDelete()

I'm not sure what the problem is though.

Link to comment
Share on other sites

A few things:

* Why are you using ClipPut and ClipGet like that?

* Your AutoIt installation is out of date, not to mention that the beta is older than the stable.

* Is there anything wrong with native functions?

Thanks for for pointing out that I am out of date. I haven't had an issue until now so I wanted to ask if I was doing something really wrong before updating. As for ClipPut and ClipGet, I am quicker with Ctrl+v than with all the mouse movement required to do repetative markup with just the buttons. There probably is a better way but I was getting the idea down on paper, if you will, then I planned on going back and refining the process.

Also, thanks for the altered code. Unfortunately it didn't change the outcome. I have come accross what appears to be a 589 line limit for my system or how I am doing things. What I have been doing is reading the scripts via Putty and copying them out to notepad. I have another script I put together to do some markup and it is able to read all of the lines but it is using different features and does a standard change accross the board. I will include it below in case it is helpful. Either way when I add text to line 590 then I can only cut or delete from the edit box using the code I posted above. I didn't realise that this was the case until after I had posted. I will update my AutoIt installation to see if this changes things.

I am sorry, but if I have not answered "Is there anything wrong with native functions?" it is because I am not sure what you are refering to.

Thanks again,

Casey

Other code for mass markup:

#RequireAdmin
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#CS
    
    AutoIt
    Created: 26MAY2011
    Author: Casey
    
    Purpose: Convert a text file to [@ @]\\ format. Copy script contents from CAT command in
    Putty Window into a TXT file then run this against it to write [@ at the beginning
    of each line and @]\\ at the end of each line to make putting scripts into the WIKI
    a bit easier.
    
    Conditions:
    
    1. You want to convert a script that you copied out of putty into notepad or some other
    text file to have [@ at the beginning of each line and @]\\ at the end of each line.
    
    Perks:
    
    1. Save alot of alot of typing.
    
    2. Save alot of human errors that cost time.
    
    3. When done from .TXT file verses .DOCX there are no problems with a long "-" being
    interpreted by putty as a period when you copy and paste from the WIKI to complete a
    procedure.
    
#CE
;Declare variables
Dim $aRecords, $beginning, $ending
;Set contents of variables
$beginning = "[@"
$ending = "@]\\"
;Text for file select dialog message
$message = "Browse for the file you wish to alter all lines to have [@ at the beginning and @]\\ at the end."
;Open dialog to search and select the file you want to convert
$var = FileOpenDialog($message, @ScriptDir & "\", "Text files (*.txt)", 1 + 2)
;Some error checking
If @error Then
    MsgBox(4096, "Chicken", "No File(s) chosen")
Else
    $MakeItHappen = MsgBox(1, "You chose " & $var, "Do you want to process the file ?")
    If $MakeItHappen == 1 Then
        ;Error checking to ensure array was able to be created
        If Not _FileReadToArray($var, $aRecords) Then
            MsgBox(4096, "Error", " Error reading log to Array     error:" & @error)
            Exit
        EndIf
        For $x = 1 To $aRecords[0]
            ;Display current array record
            ;MsgBox(0, 'Record:' & $x, $aRecords[$x])
            ;Create variable using current array position contents and add WIKI markup before and after
            If $aRecords[$x] == "" Then
                $var2 = $beginning & "#" & $aRecords[$x] & $ending
            Else
                $var2 = $beginning & $aRecords[$x] & $ending
            EndIf
            ;Replace current array position contents with modified contents
            _ArraySwap($aRecords[$x], $var2)
        Next
        ;View results in array display dialog
        ;_ArrayDisplay($aRecords)
        ;Set new file name as variable
        $var4 = _NowTime(5)
        $var5 = StringReplace($var4, ":", "_", 0)
        $var6 = _NowDate()
        $var7 = StringReplace($var6, "/", "_", 0)
        $sFile = $var & "_Modified_" & $var7 & "_" & $var5 & ".txt"
        ;Create new file from Array
        _FileWriteFromArray($sFile, $aRecords, 1)
        ;Release the file
        FileClose($sFile)
        ;Open new file for reading
        Run("notepad.exe " & $sFile)
    ElseIf $MakeItHappen = 2 Then
        ;User Canceled
    EndIf
EndIf
Exit (0)
Edited by Casey
Link to comment
Share on other sites

I will update my AutoIt installation to see if this changes things.

Per our discussion I have updated to the most current version and the behavior is still the same. Still wondering why this is happening as I can see the whole contents of the text file populated within the edit control. Is there some limitation on FileRead?

Thanks,

Casey

Link to comment
Share on other sites

Still wondering why this is happening as I can see the whole contents of the text file populated within the edit control.

Ok, I sorry to have wasted your time. It figures that I would find the cause only after seeking help. The answer appears to be the lack of _GUICtrlEdit_SetLimitText. When I check the default character limit using _GUICtrlEdit_GetLimitText, I find that it is set at 30,000. When I change it to much more than that the control behaves the way that I want it to.

Again, my apologies.

Casey

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