Jump to content

Recommended Posts

Posted (edited)

I tried going through your code, I'm not sure if this is what you are looking for, but maybe it will give you ideas

#include <array.au3>

$VmApl = "da=397 ga=398 ca=399 fa=400 ta=401 ua=402 -officepro tbd=120"

$array = StringRegExp($VmApl, "(\w+)=(\d+)", 2)
_arrayDisplay($array, "$VmApl")

Msgbox(0, "", _getValue_RoutDev( "RouteDev"))
Msgbox(0, "", _getValue_TrunkDev( "TrunkDev"))


Func _getValue_RoutDev($Label_RoutDev)
    
    $sOut = $array[0] & " = " & $array[1]
    Return $sOut
    
EndFunc 


Func _getValue_TrunkDev($Label_TrunkDev)
    
    $sOut = $array[2] & " = " & $array[3]
    Return $sOut
    
EndFunc

If you need the -officepro data too, then make the regexp "(\w+)=(\d+)|(-\w+)"

Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

@SteveR:

Thank you for helping, but there is an error, if I run the program

$array = StringRegExp($VmApl, "(\w+)=(\d+)", 2)

$array = ^ ERROR

Posted (edited)

@Markir

StringRegExp is not a public released function. It was withdrawn from 3.1, for not being finalized of bugs.

A beta has been released, to sample, in the developers forum, which contains this function.

Edit: If you want the beta files, get it from this thread.

Edited by MHz
Posted (edited)

This is the correct way:

$array = StringRegExp("(\w+)=(\d+)", 2)

Edit:

I forgot the syntax. The above is incorrect.

and Mhz is right.

Edited by SlimShady
Posted

Okay I have download the Beta Version and now it functioned. But I have one question about your code:

Now it displayed for example "PlayDEv=792" but I need "PlayDev 792,793,794,795"

Posted (edited)

This is my codé:

#include <array.au3>

$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")



$array = StringRegExp($VmApl, "(\w+)=(\d+)", 2)


_arrayDisplay($array, "$VmApl")

Msgbox(0, "", _getValue_RoutDev( "RouteDev"))
Msgbox(0, "", _getValue_TrunkDev( "TrunkDev"))


ExitLoop
   EndIf
WEnd

Func _getValue_RoutDev($Label_RoutDev)
    
    $sOut = $array[0] & " = " & $array[1]
    Return $sOut
    
EndFunc 


Func _getValue_TrunkDev($Label_TrunkDev)
    
    $sOut = $array[2] & " = " & $array[3]
    Return $sOut
    
EndFunc
Edited by Markir
Posted

Okay I have download the Beta Version and now it functioned. But I have one question about your code:

Now it displayed for example "PlayDEv=792" but I need "PlayDev 792,793,794,795"

<{POST_SNAPBACK}>

I don't understand where the numbers are coming from. Show me the PlayDev registry string and then show me exactly how you need it to look in the MsgBox
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Posted

This is the registry input:

RoutDev=

TrunkDev=9601-9630

PlayDev=792,793,794,795

PickTimeout=15

PickHome=20

And for example, I need PlayDev=792,793,794,795

I hope you understand what I mean

Posted

Like this?

#include <array.au3>

$VmApl = "RoutDev= TrunkDev=9601-9630 PlayDev=792,793,794,795 PickTimeout=15 PickHome=20"

$array = StringRegExp($VmApl, "(\d+,?)", 2)
;_arrayDisplay($array, "$VmApl")

Msgbox(0, "", _getValue_RoutDev( "RouteDev"))
;Msgbox(0, "", _getValue_TrunkDev( "TrunkDev"))


Func _getValue_RoutDev($Label_RoutDev)

    $sOut = "PlayDev=" & $array[2] &"," & $array[3] & "," & $array[4] & "," & $array[5]
    Return $sOut

EndFunc


;Func _getValue_TrunkDev($Label_TrunkDev)
;
;   $sOut = $array[2] & " = " & $array[3]
;   Return $sOut
;
;EndFunc
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Posted (edited)

If this isn't what you need, maybe you can take some screenshots of regedit so i can see exactly what it looks like.

I made a test key in my registry so i could figure it out. Just replace the keys with yours

#include <array.au3>

$enum = 1
While 1
    $subKey = RegEnumVal("HKEY_CURRENT_USER\test",$enum)
    If @error Then ExitLoop

    $val = RegRead("HKEY_CURRENT_USER\test", $subKey)
    If @error Then ExitLoop

    _showMsg()

    $enum = $enum + 1
wEnd


func _showMsg()
        msgBox(4096, "Test", $subKey & "=" & $val)
endFunc

this is a snap of my regedit:

Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Posted

@SteveR:

There is one more problem.... :-(

See at the screenshot, if there is a value for RoutDev, for example 400-403, then the information for PlayDev are not the right one....

Any idea?

Posted (edited)

I didnt use regexp because i think there was a bug and it made autoit crash but hope you can use this:

#include <array.au3>

$VmApl = "RoutDev=400-403 TrunkDev=9601-9630 PlayDev=792,793,794,795 PickTimeout=15 PickHome=20"

$array = stringSplit($VmApl, " ", 0)

for $e = 1 to ($array[0])

    msgBox(0, "Display element " & $e, $array[$e] )

next
Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Posted

I understand what you mean with crashing autoit, but your version display me all informations in one msgbox, but i need five mesgboxes, for every line one

  • Developers
Posted

I understand what you mean with crashing autoit, but your version display me all informations in one msgbox, but i need five mesgboxes, for every line one

<{POST_SNAPBACK}>

i get 5 messageboxes with the last posted script.... :)

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

Posted (edited)

Oh sorry thanks for controling

Edit:

But it doesn't work with the regkey???

Here is the code:

#include <array.au3>

$VmApl = Regread("HKLM\SOFTWARE\PP-COM\MRS\VmAPL\01", "ParamBlock")
;$VmApl = "RoutDev=400-403 TrunkDev=9601-9630 PlayDev=792,793,794,795 PickTimeout=15 PickHome=20"

$array = stringSplit($VmApl, " ", 0)

for $e = 1 to ($array[0])

    msgBox(0, "Display element " & $e, $array[$e] )

next
Edited by Markir

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
  • Recently Browsing   0 members

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