Jump to content

String Function


Markir
 Share

Recommended Posts

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=120

I 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?

Link to comment
Share on other sites

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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
Link to comment
Share on other sites

  • 2 weeks later...

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 ?

#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
Link to comment
Share on other sites

Another Question:

I have the following Code:

$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?

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

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 Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...