Markir 0 Posted February 21, 2005 Hello everybody,I have a question of the string function. I have read in the AutoItHelp, but I think I don't find the right function for me.I use the following Code:$regstring = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\PP-COM\MRS\IsdnApl\Protocols\01", "ParamBlock") $var = StringMid($regstring,4,4) MsgBox(0, "String Test", $var)In this Registrykey is the following text:da=397 ga=398 ca=399 fa=400 ta=401 ua=402 -officepro tbd=120I want to read the "397", "398",...., "402", but the lenght of the number can be variable, for example the text could be "8000", "8001",...,"8005".Can somebody give me a tip? Share this post Link to post Share on other sites
Josbe 1 Posted February 21, 2005 Here a small tip(proof), you could try another ways too: $sVar = "da=397 ga=398555 ca=399 fa=400 ta=401 ua=402 -officepro tbd=120" Msgbox(0, "", _getValue( "ua" )) Func _getValue( $sLabel ) $sOut = StringTrimLeft( $sVar, StringInStr($sVar, $sLabel & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=")+1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Share this post Link to post Share on other sites
Markir 0 Posted February 21, 2005 Thank you this code give me the right function, I need. Share this post Link to post Share on other sites
Markir 0 Posted February 24, 2005 Hello Josbe, I have one more question about the String Function: How can I get a string till a ","? I have a variable which is "Administrator,xxxx" and I want to get the word before the ",". Share this post Link to post Share on other sites
MHz 80 Posted February 24, 2005 $result = StringSplit('Administrator,xxxx', ',') $result is an array. $result[1] should equal Administrator. $result[2] should equal xxxx Share this post Link to post Share on other sites
Markir 0 Posted February 24, 2005 Thanks I have got the first value! Share this post Link to post Share on other sites
Markir 0 Posted March 5, 2005 I have one question for the following script: It does work so far, but if the registry key don't have values "FA", "TA" or "UA" the script writes the values of "DA", "GA" and "CA", but this isn't right for the function... What can I do ? expandcollapse popup#Region PhoneMail Abfrage $PM_Protocol = 1 While 1 $key = RegEnumKey("HKLM\SOFTWARE\PP-COM\MRS\IsdnApl\Protocols",$PM_Protocol) If @error Then ExitLoop $str = RegRead("HKLM\SOFTWARE\PP-COM\MRS\IsdnApl\Protocols\" & $key,"Name") $PM_Protocol = $PM_Protocol + 1 If $str = ("PhoneMail") Then $PM_Protocol = Regread("HKLM\SOFTWARE\PP-COM\MRS\IsdnApl\Protocols\" & $key, "ParamBlock") Msgbox(0,"Test",$PM_Protocol) Msgbox(0, "", _getValue_PM_Direct_Access( "DA")) Msgbox(0, "", _getValue_PM_Direct_Access( "GA")) Msgbox(0, "", _getValue_PM_Direct_Access( "CA")) Msgbox(0, "", _getValue_PM_Direct_Access( "FA")) Msgbox(0, "", _getValue_PM_Direct_Access( "TA")) Msgbox(0, "", _getValue_PM_Direct_Access( "UA")) ExitLoop EndIf WEnd #EndRegion PhoneMail Abfrage #Region PhoneMail Einstellungen Func _getValue_PM_Direct_Access($Label_PM_Direct_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Direct_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Direct_Access Func _getValue_PM_Guest_Access($Label_PM_Guest_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Guest_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Guest_Access Func _getValue_PM_Callback_Access($Label_PM_Callback_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Callback_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Callback_Access Func _getValue_PM_Fax_Access($Label_PM_Fax_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Fax_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Fax_Access Func _getValue_PM_Transfer_Access($Label_PM_Transfer_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Transfer_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Transfer_Access Func _getValue_PM_Universal_Access($Label_PM_Universal_Access) $sOut = StringTrimLeft($PM_Protocol, StringInStr($PM_Protocol, $Label_PM_Universal_Access & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc ;==>_getValue_PM_Universal_Access #EndRegion PhoneMail Einstellungen Share this post Link to post Share on other sites
Markir 0 Posted March 5, 2005 Another Question: I have the following Code: expandcollapse popup$VmApl = 1 While 1 $key = RegEnumKey("HKLM\SOFTWARE\PP-COM\MRS\VmApl",$VmApl) If @error Then ExitLoop $str = RegRead("HKLM\SOFTWARE\PP-COM\MRS\VmAPL\" & $key,"ScriptName") $VmApl = $VmApl + 1 If $str = ("acd.e") Then $VmApl = Regread("HKLM\SOFTWARE\PP-COM\MRS\VmAPL\" & $key, "ParamBlock") Msgbox(0, "", _getValue_RoutDev( "RouteDev")) Msgbox(0, "", _getValue_TrunkDev( "TrunkDev")) Msgbox(0, "", _getValue_PlayDev( "PlayDev")) Msgbox(0, "", _getValue_PickTimeOut( "PickTimeOut")) Msgbox(0, "", _getValue_PickHome( "PickHome")) ExitLoop EndIf WEnd Func _getValue_RoutDev($Label_RoutDev) $sOut = StringTrimLeft($VmApl, StringInStr($VmApl, $Label_RoutDev & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc Func _getValue_TrunkDev($Label_TrunkDev) $sOut = StringTrimLeft($VmApl, StringInStr($VmApl, $Label_TrunkDev & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc Func _getValue_PlayDev($Label_PlayDev) $sOut = StringTrimLeft($VmApl, StringInStr($VmApl, $Label_PlayDev & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc Func _getValue_PickTimeOut($Label_PickTineOut) $sOut = StringTrimLeft($VmApl, StringInStr($VmApl, $Label_PickTineOut & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc Func _getValue_PickHome($Label_PickHome) $sOut = StringTrimLeft($VmApl, StringInStr($VmApl, $Label_PickHome & "=")) $sOut = StringMid($sOut, StringInStr($sOut, "=") + 1, (StringInStr($sOut, " ") - StringInStr($sOut, "="))) Return $sOut EndFunc The value of the Regkey is the following: RoutDev= TrunkDev=9601-9630 PlayDev=792,793,794,795 PickTimeout=15 PickHome=20 And I need the values after the "=" in the different msgbox. Can somebody help me, please? Share this post Link to post Share on other sites
Jos 2,165 Posted March 5, 2005 where are these WORDS exactly located in the registry : RoutDev= TrunkDev=9601-9630 PlayDev=792,793,794,795 PickTimeout=15 PickHome=20 Under one of these ? RegEnumKey("HKLM\SOFTWARE\PP-COM\MRS\VmApl",$VmApl) RegRead("HKLM\SOFTWARE\PP-COM\MRS\VmAPL\" & $key,"ScriptName") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Markir 0 Posted March 5, 2005 Hi, all these parameters are under this key "RegRead("HKLM\SOFTWARE\PP-COM\MRS\VmAPL\" & $key,"ScriptName")" in one row not in a block Share this post Link to post Share on other sites
Markir 0 Posted March 7, 2005 @Jdeb, Do you found something in the code, to extract the keys? Share this post Link to post Share on other sites
Markir 0 Posted March 8, 2005 @Jedb: Do you have some information for me? Share this post Link to post Share on other sites
SumTingWong 1 Posted March 8, 2005 @Jedb:Do you have some information for me?<{POST_SNAPBACK}>Why don't you export the key to a file and paste content here. It would help with figuring out what you are trying to do. Share this post Link to post Share on other sites
Markir 0 Posted March 8, 2005 This is the regkey:RoutDev=TrunkDev=9601-9630PlayDev=792,793,794,795PickTimeout=15PickHome=20And I want to have the values after the "="! Share this post Link to post Share on other sites
Nutster 3 Posted March 9, 2005 This is the regkey:And I want to have the values after the "="!<{POST_SNAPBACK}>Try extracting them with the StringRegExp in the beta. For each line, do:$array = StringRegExp("(\w+)\s*=\s*(\d+)", $regstring, 1)The array will contain the name of value in element 0, and the number will be in element 1. The number will stored as a string, but it is easy enough to convert. David NuttallNuttall Computer ConsultingAn Aquarius born during the Age of AquariusAutoIt allows me to re-invent the wheel so much faster.I'm off to write a wizard, a wonderful wizard of odd... Share this post Link to post Share on other sites
Markir 0 Posted March 9, 2005 How can I integrated your Code to my Code? Share this post Link to post Share on other sites
Markir 0 Posted March 15, 2005 Why does nobody help me, to solve my problem? Share this post Link to post Share on other sites
Markir 0 Posted March 17, 2005 @Jdeb, have you any idea, how I can realise it? Share this post Link to post Share on other sites
steveR 0 Posted March 17, 2005 Try extracting them with the StringRegExp in the beta. For each line, do:$array = StringRegExp("(\w+)\s*=\s*(\d+)", $regstring, 1)The array will contain the name of value in element 0, and the number will be in element 1. The number will stored as a string, but it is easy enough to convert.<{POST_SNAPBACK}>I think maybe it should be written like this:$array = StringRegExp($regstring, "(\w+)\s*=\s*(\d+)", 1) AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Share this post Link to post Share on other sites
Markir 0 Posted March 17, 2005 @SteveR: Can you say it to me with the whole code??? Share this post Link to post Share on other sites