Jump to content
Fractured

Edit Window @CRLF issue

Recommended Posts

Ok, so I have a script that checks a drive to find the latest firmware Rev and Test Procedure Rev for the units I test.

It basically loads the filenames into an array and checks it verse what was selected and displays the current on file Rev.

I used an Edit box for the Test Procedure File Revs since some files are pdf, doc, docx, or all 3 types!! Wanted to list all 3.

You will see my horrible coding!! BUT the edit box wont take an @CRLF command to goto next line to for each type of file found....Not sure why... I know im not using the StringinStr return correctly but it works for what im doing!! LOL!! Any help on the @crlf problem would be great!!

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=K:\Work\AutoIT Scripts\Mine\Icons\DXP_Options_PrinteSettings_ICON.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ============================ # Header # =============================================================
     Title ............: Revision Tracker
     Description ......: Checks the latest Rev of the firmware file
     Script Version ...: 1
     Author ...........: Charles Wright
     Language .........:
     AutoIt Version ...:
     Notes ............: Requires Initinfo.ini

     Version History ..:
#ce ============================ # Header # =============================================================



; ========================================================================================================
#Region Main Includes ------------------------------------------------------------------------------------
; ========================================================================================================
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

; ========================================================================================================
#EndRegion Main Includes ------------------------------------------------------------------------------------
; ========================================================================================================

; ========================================================================================================
#Region Main Variables -----------------------------------------------------------------------------------
; ========================================================================================================
Global $o_Current, $o_ATPrev, $Debug
Global $Space = @CRLF
Global $aCurrentRevList
Global $aRevDataLive
Global $g_sFilePatha = "\\frd-s-fil01.ad.apitech.com\data\Drawing Vault\DWG VAULT\IcPrograms"
Global $g_sFilePathb = "\\frd-s-fil01.ad.apitech.com\data\Drawing Vault\DWG VAULT\ATP"
Global $sFilePath = @ScriptDir & "\IcRev.txt"
Local $aListModel = IniReadSectionNames(@ScriptDir & "\RevTracker.ini") ; IniReadSectionNames ( "filename" )
$sMatch = ""
; ========================================================================================================
#EndRegion Main Variables -----------------------------------------------------------------------------------
; ========================================================================================================

; ========================================================================================================
#Region Main GUI Creation --------------------------------------------------------------------------------
; ========================================================================================================
#Region ### START Koda GUI section ### Form=C:\Mine_Autoit\Models\IcProg\RevCheckerv1.kxf
$g_Core = GUICreate("Firmware  Rev Checker v1", 343, 332, 260, 148, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME))
GUISetBkColor(0x000000)
$Label1 = GUICtrlCreateLabel("Unit", 96, 16, 33, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Unit = GUICtrlCreateCombo("Unit", 56, 40, 121, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$b_Check = GUICtrlCreateButton("Check", 240, 56, 75, 65, BitOR($BS_CENTER, $BS_VCENTER))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
$Label3 = GUICtrlCreateLabel("Current Firmware", 24, 80, 185, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$o_Current = GUICtrlCreateInput("", 24, 104, 185, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$l_ATPrev = GUICtrlCreateLabel("ATP Rev", 144, 140, 66, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$o_ATPrev = GUICtrlCreateEdit("", 20, 170, 305, 149, $ES_MULTILINE)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)

For $i = 1 To $aListModel[0]
    GUICtrlSetData($Unit, $aListModel[$i])
Next

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; ========================================================================================================
#EndRegion Main GUI Creation --------------------------------------------------------------------------------
; ========================================================================================================

_ICRev()

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            GUIDelete($g_Core)
            Exit

        Case $b_Check
            GuiCtrlSetData($o_ATPrev, "")
            $uUnit = GUICtrlRead($Unit)
            _ICRevModify($uUnit, $o_Current)
            _ATPRevModify($uUnit, $o_ATPrev)


    EndSwitch
WEnd

; ========================================================================================================
#Region Internal Functions -------------------------------------------------------------------------------
; ========================================================================================================

; #FUNCTION# =============================================================================================
; Name ..........: _ICRev()
; Syntax ........: _ICRev()
; Argument(s)....: None
; Remarks .......: Builds array from Ic Programs directory
; Return Value ..:
; Example .......:
; ========================================================================================================
Func _ICRev()

    Global $aCurrentRevList = _FileListToArray($g_sFilePatha, "*.hex")
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf

    Global $aCurrentATPRevList = _FileListToArray($g_sFilePathb, "*.*")
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf

EndFunc   ;==>_ICRev

; #FUNCTION# =============================================================================================
; Name ..........: _ICRevModify()
; Syntax ........: _ICRevModify()
; Argument(s)....: None
; Remarks .......: Rebuilds new array for IC search
; Return Value ..: $aRevDataLive - Ic Program Versions
; Example .......:
; ========================================================================================================
Func _ICRevModify($uUnit, $o_Current)
    Local $iniFirmware = "" & IniRead(@ScriptDir & "\RevTracker.ini", $uUnit, "Firmware", "") & "" ;IniRead ( "filename", "section", "key", "default" )
    Local $sRevData = _ArrayToString($aCurrentRevList, "|")
    Local $sRevDataTemp = StringReplace($sRevData, ".hex", "", 0)
    Local $aRevDataLive = StringSplit($sRevDataTemp, "|")
    For $i = 1 To $aRevDataLive[0]
        $Temp = $aRevDataLive[$i]
        $Temp2 = StringTrimRight($Temp, 1)

        If $iniFirmware = $Temp2 Then
            GUICtrlSetData($o_Current, $Temp)
        EndIf

    Next

EndFunc   ;==>_ICRevModify

; #FUNCTION# =============================================================================================
; Name ..........: _ATPRevModify()
; Syntax ........: _ATPRevModify()
; Argument(s)....: None
; Remarks .......: Rebuilds new array for ATP search
; Return Value ..: $aRevDataLive - ATP Program Versions
; Example .......:
; ========================================================================================================
Func _ATPRevModify($uUnit, $o_ATPrev)
    Local $atpFirmware = "" & IniRead(@ScriptDir & "\RevTracker.ini", $uUnit, "ATP", "") & "" ;IniRead ( "filename", "section", "key", "default" )
    Local $satpRevData = _ArrayToString($aCurrentATPRevList, "|")
    Local $aatpRevDataLive = StringSplit($satpRevData, "|")

    _ArrayDisplay($aCurrentATPRevList)

    For $i = 1 To $aatpRevDataLive[0]
        $atpTemp = $aatpRevDataLive[$i]

        $Debug = StringinStr($atpTemp, $atpFirmware, 0, 1, 1, 8)
        ;MsgBox($MB_SYSTEMMODAL, "Debug", $atpTemp & " - " & $Debug, 10)


        If $Debug = 1 Then
            GuiCtrlSetData($o_ATPrev, $atpTemp & @CRLF)

        Endif

    Next

EndFunc   ;==>_ICRevModify


; ========================================================================================================
#EndRegion Internal Functions -------------------------------------------------------------------------------
; ========================================================================================================

 

Share this post


Link to post
Share on other sites

You must use the 3rd parameter to set data :

GuiCtrlSetData($o_ATPrev, $atpTemp & @CRLF, 1)

Otherwise it will simply replace the text of the edit box...(look help file for more details)

Share this post


Link to post
Share on other sites

Thanks @Nine….missed that in the help but found _GUICtrlEdit_AppendText($o_ATPrev,  $atpTemp & @CRLF) right as you posted!! 

I thought the 3rd param was for default txt....my bad!!!!

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...