mlewis412 Posted December 16, 2014 Share Posted December 16, 2014 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: expandcollapse popup; 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 More sharing options...
computergroove Posted December 16, 2014 Share Posted December 16, 2014 FileOpen ("C:\NextGen\" & $stringhere & "\Version.txt",0) Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
MikahS Posted December 16, 2014 Share Posted December 16, 2014 just need to seperate using '&' like so "C:NextGen" & $stringhere & "Version.txt" Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
mlewis412 Posted December 16, 2014 Author Share Posted December 16, 2014 Awesome! Thank you guys, I feel like a dumby ..lol Link to comment Share on other sites More sharing options...
MikahS Posted December 16, 2014 Share Posted December 16, 2014 Don't! We all learn differently and at different paces. It's what we are here for. TheSaint 1 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
Exit Posted December 16, 2014 Share Posted December 16, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now