Jump to content

Question in regards to Extracting data from a text file using FileOpen


 Share

Recommended Posts

Hello all, 

Please go easy on me as I am new to autoit. I have searched the help and google but was not able to locate what I am looking for. I was wondering if there is a way to use a string when using FileOpen. 

For instance : FileOpen ("C:NextGen$stringhereVersion.txt",0)

Below is my script:

; AutoIt GUI
; Modifed: 12/10/2014 - Michael Lewis


#include <AVIConstants.au3>
#include <GuiConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <MsgBoxConstants.au3>


; GUI
GUICreate("EPM Tools - By Michael Lewis", 400, 400)




$iButton1 = GUICtrlCreateButton("EPM PID #", 20, 20, 185, 22)
$iButton2 = GUICtrlCreateButton("Encounter # Copy", 20, 50, 185, 22)
$iButton3 = GUICtrlCreateButton("?", 220, 50, 20, 22)
$iButton4 = GUICtrlCreateButton("Database and Hotfix", 20, 80, 185,22)
$iInput = GUICtrlCreateInput ("", 250,2,140,300) ;Encounter input
$iInput = GUICtrlCreateInput ("", 20,110,80,22) ;Database input
$iInput = GUICtrlCreateInput ("", 110,110,80,22) ;Hotfix input


; MAIN Function
GUISetState(@SW_SHOW)


Local $iMsg = 0


While 1
    $iMsg = GUIGetMsg()
    $winexist= WinExists ("Untitled - Notepad")
    $encounter = ControlGetText("NextGen -", "", "[NAME:_lblVisGen_1]")
$winactivate =WinActivate ("Untitled - Notepad")
$database = ControlGetText ("NextGen -", "", "[NAME:pnlDatabase]")
    $file= FileOpen ("C:\NextGen\NG58_83\Version.txt",0)
    $last_line = FileReadLine ($file, -1)


    Switch $iMsg


Case $GUI_EVENT_CLOSE
            Exit


Case $iButton1 ;EPM PID Finder
            Local $sText = WinGetProcess("NextGen -")
MsgBox($MB_SYSTEMMODAL, "EPM PID", $sText)


Case $iButton2 ;Encounter Copier Button


ControlSetText("EPM Tools - By Michael Lewis", "", "[CLASS:Edit; INSTANCE:1]", $encounter)








Case $iButton3 ;Tooltip box for Encounter Copier
MsgBox($MB_SYSTEMMODAL, "Encounter Copy", "When you have the patients chart > encounters window open and an encounter selected, click this button and it will copy the encounter to a blank notepad")


Case $iButton4 ;Database & Hotfix


ControlSetText("EPM Tools - By Michael Lewis", "", "[CLASS:Edit; INSTANCE:2]", $database)


If $file = -1 Then
MsgBox(16, "Error", "Unable to open file.")
    EndIf
MsgBox (0,"Finish reading", $last_line, 0)


EndSwitch


WEnd
Link to comment
Share on other sites

just need to seperate using '&'

like so

"C:NextGen" & $stringhere & "Version.txt"

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Don't! We all learn differently and at different paces. It's what we are here for. ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

There is also another way to substitute variables in a string using Opt("ExpandVarStrings", 1)

 

Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand

;~ Changes how literal strings and variable/macro ($ and @) symbols are interpreted.
;~ By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$".
;~ 0 = (default) do not expand variables
;~ 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign".

$stringhere = "NG58_83"

ConsoleWrite("@CRLF@ C:\NextGen\$stringhere$\Version.txt @CRLF@@CRLF@")

$file = FileOpen("C:\NextGen\$stringhere$\Version.txt", 0)

App: Au3toCmd              UDF: _SingleScript()                             

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