Jump to content

Recommended Posts

Posted

Hello everyone,

Need help please. I can't figure out the 'pattern' to use to get a match.

My code so far

#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>

$gui = GUICreate("Sample", 100, 100, -1, -1)
$input = GUICtrlCreateInput("", 5, 10, 90, 20)
$button = GUICtrlCreateButton("Change", 5, 50, 90, 30)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $button
            $Line3 = FileReadLine("MyFile.txt", 3)
            $Result = StringRegExp($Line3, 'NEED HELP AT THIS PART', 1) ;; <-- I'm stuck here. The ones in bold. Don't know the correct code to use.
            $File = FileRead('MyFile.txt', FileGetSize('MyFile.txt'))
            $File = StringReplace($File,$Result[0], GUICtrlRead($input))
            FileOpen('MyFile.txt',2)
            FileWrite('MyFile.txt',$File)
    EndSwitch

WEnd

I was hoping that after I clicked on 'Change' button, what I entered at the inputbox will replace that spot in line 3 having the below sample patterns, quotes included.

"6B3T"

"2K8F"

"4X9S"

In other words, if line 3 of 'MyFile.txt' reads

Any text for that matter here "6B3T"

...and I typed 7A8V at the box, line 3 of 'MyFile.txt' would be changed to (after button click)

Any text for that matter here "7A8V"

Any assitance along this matter would be much appreciated. Thank you. ;)

bumblebee is a newbie...so help me God.

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