dnlwilson Posted August 18, 2011 Share Posted August 18, 2011 I have a dos batch file I would like to integrate in with other autoit functions, but not sure how to replace. Here is what the DOS batch does: for /f "skip=2 tokens=1-4 delims=," %%a in ('find /i "%ClientName%" "%Client-TTYIDFileLocation%\%Client-TTYIDFileName%"') do if not [%%b]==[] ( if [%%c]==[] goto ERR if [%%d]==[] goto ERR call :Normal %%b %%c %%d goto end ) :Normal call %haPath%\%haEXE% /TTYID=%1 /HOST=%CAFHost% /PORT=%CAFPort% goto end Basically there is a file that has a list of clientnames so it searches for a match and grabs the TTY,Host, and port from that file that matches for that client id and uses those values as parameters to start a program. Any ideas? Link to comment Share on other sites More sharing options...
Bert Posted August 18, 2011 Share Posted August 18, 2011 Look at arrays in the help file. The examples there should give you a good idea on what to do The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 20, 2011 Share Posted August 20, 2011 Looked like fun, so I took a stab at it: #include <File.au3> Opt("ExpandEnvStrings", 1) Global $sClientName = "%ClientName%" Global $sFile = "%Client-TTYIDFileLocation%\%Client-TTYIDFileName%" Global $aFile[1], $aSplit[1] _FileReadToArray($sFile, $aFile) For $n = 1 To $aFile[0] $aSplit = StringSplit($aFile[$n], ",") If $aSplit[0] >= 6 Then If $aSplit[4] <> "" Then If ($aSplit[5] <> "") And ($aSplit[6] <> "") Then _Normal($aSplit[4], $aSplit[5], $aSplit[6]) Else _Error() EndIf EndIf EndIf Next Func _Normal($sB, $sC, $sD) #forceref $sC, $sD Run("%haPath%\%haEXE% /TTYID=" & $sB & " /HOST=%CAFHost% /PORT=%CAFPort%") EndFunc ;==>_Normal Func _Error() MsgBox(16, "Error", "Error") Exit EndFunc ;==>_Error There are some extra variables with no use here, but it reflects the posted batch script. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
dnlwilson Posted August 23, 2011 Author Share Posted August 23, 2011 Thanks, I will give it a shot -looks promising! Looked like fun, so I took a stab at it: #include <File.au3> Opt("ExpandEnvStrings", 1) Global $sClientName = "%ClientName%" Global $sFile = "%Client-TTYIDFileLocation%\%Client-TTYIDFileName%" Global $aFile[1], $aSplit[1] _FileReadToArray($sFile, $aFile) For $n = 1 To $aFile[0] $aSplit = StringSplit($aFile[$n], ",") If $aSplit[0] >= 6 Then If $aSplit[4] <> "" Then If ($aSplit[5] <> "") And ($aSplit[6] <> "") Then _Normal($aSplit[4], $aSplit[5], $aSplit[6]) Else _Error() EndIf EndIf EndIf Next Func _Normal($sB, $sC, $sD) #forceref $sC, $sD Run("%haPath%\%haEXE% /TTYID=" & $sB & " /HOST=%CAFHost% /PORT=%CAFPort%") EndFunc ;==>_Normal Func _Error() MsgBox(16, "Error", "Error") Exit EndFunc ;==>_Error There are some extra variables with no use here, but it reflects the posted batch script. 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