Sign in to follow this  
Followers 0
iamtheky

Quotes issue [Solved]

6 posts in this topic

#1 ·  Posted (edited)

the script i am working on scours an au3 for regwrites - and makes an au3 filled with regread statements for those keys. A simpler version worked fine, but as I try to make it a little

This is 'colored' in scite correctly with my intent, with $log being a string in this script but a variable in the next, and the array items being variables in this script resulting in strings in the next.

Still playing with quote configuration but no luck yet. Thanks for any assistance.

$RegArray[$i] = 'If Regread(" '& $stringArray[0] & "," & $stringArray[1] & ") <> "" Then'" & @CRLF & _
    'filewrite($log & "," ' & $stringArray[0] & "," & $stringArray[1] & '=' &  Regread($stringArray[0] & "," & $stringArray[1])'' & @CRLF & _
    'Else' & @CRLF & _
    'filewrite($log & "," ' & $stringArray[0] & "," & $stringArray[1] & '= "Empty or Does Not Exist")' & @CRLF & _
    "Endif" & @CRLF & _
    @CRLF
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



The file you write should contain something like this?

$key = "keyname"
    $value = "valuename"
    $RegData = Regread($key, $value)
    If $RegKey <> "" Then
        filewrite($log, $key & "," & $value & " = " & $RegData)
    Else
        filewrite($log, $key & "," & $value & " = Empty or Does Not Exist")
    Endif

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

if yes, then the script should look like;

Global $stringArray[2] = ["keyname", "valuename"]
Global $RegArray[1]

$RegArray[0] = '$key = "' & $stringArray[0] & '"' & @CRLF & _
        '$value = "' & $stringArray[1] & '"' & @CRLF & _
        '$RegData = Regread($key, $value)' & @CRLF & _
        'If $RegKey <> "" Then' & @CRLF & _
        '    filewrite($log, $key & ", " & $value & " = " & $RegData)' & @CRLF & _
        'Else' & @CRLF & _
        '    filewrite($log, $key & ", " & $value & " = Empty or Does Not Exist")' & @CRLF & _
        'Endif' & @CRLF

ConsoleWrite($RegArray[0] & @CRLF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

thanks water, this seems to result in the desired output. There are still issues with the resulting file in that some of the RegRead lines blow up, I tried quoting the Keys in case it was an issue with spaces, but that does not seem to be the case.

*replaced below
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

The example you now posted doesn't look like you implemented my code :)

Can you implement my code and try again?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I did, but then then some regreads blew up. Then ctrl-z'ed two too many times. ultimately I had to remove a set of quotes and change $RegKey to $Regdata, but yours was ridiculously closer than mine. Thanks.

#Include <Array.au3>
#Include <File.au3>


$string = FileRead ("SomeUpdates.au3")

$RegArray = stringregexp ($string , "RegWrite(.*)" , 3)

for $i = 0 to ubound($RegArray) - 1
    
    $trim = stringtrimleft($RegArray[$i] , 1)
    $trim = stringtrimright($trim , 1)
    
    $stringArray = stringsplit ($trim , "," , 2)



    $RegArray[$i] = '$key = ' & $stringArray[0] & '' & @CRLF & _
        '$value = ' & $stringArray[1] & '' & @CRLF & _
    '$RegData = Regread($key, $value)' & @CRLF & _
        'If $RegData <> "" Then' & @CRLF & _
        '   filewrite($log, $key & ", " & $value & " = " & $RegData)' & @CRLF & _
        'Else' & @CRLF & _
        '   filewrite($log, $key & ", " & $value & " = Empty or Does Not Exist")' & @CRLF & _
        'Endif' & @CRLF
    
    next


    
$writefile = FileOpen("test_output.au3" , 2)

filewrite($writefile , '$log = fileopen("log.txt" , 2)' & @CRLF)

_FileWriteFromArray ($writefile , $RegArray)

filewrite($writefile , 'fileclose($log)')

FileClose($writefile)
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
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
Sign in to follow this  
Followers 0