dnlwilson 0 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? Share this post Link to post Share on other sites
Bert 1,430 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/ Share this post Link to post Share on other sites
PsaltyDS 39 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 Share this post Link to post Share on other sites
dnlwilson 0 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. Share this post Link to post Share on other sites