ur Posted December 15, 2015 Posted December 15, 2015 I need to write a code in which I am reading a text file which is of .vbs format and in that a line contains function signature like belowFunction CreateEnvironmentVariable($sType, $sName, $sValue, $bOverwrite)If the string is in above format, then I need to check number of arguments in it.For in above case it should return 4.Can anyone help me on this.
Moderators JLogan3o13 Posted December 15, 2015 Moderators Posted December 15, 2015 (edited) @ur what have you tried on your own? Look at FileReadToArray in the help file to read the file in, and parse through it line by line. You can then use StringInStr to parse each line, something like this:If StringInStr($aArray[$i], "CreateEnvironmentVariable") Then ;Count number of params EndIf Edited December 15, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
ur Posted December 15, 2015 Author Posted December 15, 2015 Got the code...#include <StringConstants.au3> $s = "Function CreateEnvironmentVariable($sType, $sName, $sValue, $bOverwrite)" MsgBox(0,"",CountArgs($s)) Func CountArgs($strFunctionName) ;to differentiate between small brackets in strings $strFunctionName = StringStripWS($strFunctionName, $STR_STRIPLEADING + $STR_STRIPTRAILING) $strFunctionName = StringReplace ( $strFunctionName, "(", "~OSBS~" , 1 ) $strFunctionName = StringReplace ( $strFunctionName, ")", "~OSBE~" , -1 ) $strFunctionName = StringReplace ( $strFunctionName, "(", "~DSBS~" ) $strFunctionName = StringReplace ( $strFunctionName, ")", "~DSBE~" ) $strFunctionName = StringReplace ( $strFunctionName, "~OSBE~" ,")", -1 ) $strFunctionName = StringReplace ( $strFunctionName, "~OSBS~","(", 1 ) Local $arrStrProcedureArguments = StringSplit ( $strFunctionName, "," ) ;_ArrayDisplay($arrStrProcedureArguments) Return $arrStrProcedureArguments[0] EndFunc
Moderators JLogan3o13 Posted December 15, 2015 Moderators Posted December 15, 2015 That would have been helpful in post 1 So what, exactly, is not working for you? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
jguinch Posted December 15, 2015 Posted December 15, 2015 Why not just this ?Func CountArgs($strFunctionName) Return UBound(StringSplit($strFunctionName, ",", 2)) EndFunc Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
JohnOne Posted December 15, 2015 Posted December 15, 2015 OrFunc CountArgs($strFunctionName) StringReplace($strFunctionName, ",", ",") Return @extended + 1 EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
ur Posted December 16, 2015 Author Posted December 16, 2015 That would have been helpful in post 1 So what, exactly, is not working for you?Yeah it is working fine now, I got the solution after posting the question.So I posted my code here.
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