Jump to content

Enclose a variable in quotes


gfunk999
 Share

Recommended Posts

Forgive me if this topic already exists. However, I spent over two hours trying to find something on this. Is there a way to enclose a variable in quotes without disabling it?

i.e. $Var = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", $Input)

Note: $Input will require the double quotes, but doing so disables the variable.

I appreciate any help :)

Link to comment
Share on other sites

$input = '"quotes"'

?

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Forgive me if this topic already exists. However, I spent over two hours trying to find something on this. Is there a way to enclose a variable in quotes without disabling it?

i.e. $Var = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", $Input)

Note: $Input will require the double quotes, but doing so disables the variable.

I appreciate any help :)

$input = "SomeInput"
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", '"' & $Input & '"')

This should make the $input to be entered into registry and look like "SomeInput" instead of SomeInput :) I hope...

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

Forgive me if this topic already exists. However, I spent over two hours trying to find something on this. Is there a way to enclose a variable in quotes without disabling it?

i.e. $Var = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", $Input)

Note: $Input will require the double quotes, but doing so disables the variable.

I appreciate any help :)

If you want to put the value of the variable inside the quotation, use the following format;

"" & $var1

Thus in your case;

$Var = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", "" & $Input)
Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Aslani, that won't work. "" = null string, not a quote. You'd have to do something more like what i posted earlier

$Var = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Alan","Name", "REG_SZ", '"' & $Input & '"')

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Thanks everyone for your replies. However, here's the code i'm using, notice that the $input_2 is getting change to 3, can't figure out why this is happening? The registry writes the 3 instead of the number I input.

#include <GuiConstants.au3>

GuiCreate("MYGUI", 262, 148,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_2 = GuiCtrlCreateInput("", 20, 20, 90, 20, $ES_NUMBER)
$Button_3 = GuiCtrlCreateButton("OK", 150, 20, 50, 21)


GuiSetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $Button_3
               exitloop
       EndSelect
Wend
if $msg = -3 Then
    Exit
    EndIf

MsgBox (4096, "Test", GUICtrlRead($Input_2))
MsgBox (0, "Test1", $Input_2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & $Input_2)
Link to comment
Share on other sites

But the actual Input is canged to 3 before it even makes it to the registry. So I think it's something how I'm using my code.

the quotation marks could be a part of regwrite and not of the actual writing maybe somone who knows how regwrite works could help you more.

Link to comment
Share on other sites

Thanks everyone for your replies. However, here's the code i'm using, notice that the $input_2 is getting change to 3, can't figure out why this is happening? The registry writes the 3 instead of the number I input.

#include <GuiConstants.au3>

GuiCreate("MYGUI", 262, 148,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_2 = GuiCtrlCreateInput("", 20, 20, 90, 20, $ES_NUMBER)
$Button_3 = GuiCtrlCreateButton("OK", 150, 20, 50, 21)
GuiSetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $Button_3
               exitloop
       EndSelect
Wend
if $msg = -3 Then
    Exit
    EndIf

MsgBox (4096, "Test", GUICtrlRead($Input_2))
MsgBox (0, "Test1", $Input_2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & $Input_2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & $Input_2)

$Input_2 is the control ID of the text field, not the value of the field. Should be GUICtrlRead($Input_2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & GUICtrlRead($Input_2))

Or, with quotes around it:

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", '"' & GUICtrlRead($Input_2) & '"')
Edited by Buey
Link to comment
Share on other sites

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & $Input_2)

$Input_2 is the control ID of the text field, not the value of the field. Should be GUICtrlRead($Input_2)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", "" & GUICtrlRead($Input_2))

Or, with quotes around it:

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ALAN", "NAME", "REG_SZ", '"' & GUICtrlRead($Input_2) & '"')
ditto...he beat me to it. :)

Just to clarify a bit.

If $Input_2 = 5

"" & GUICtrlRead($Input_2) = 5

'"' & GUICtrlRead($Input_2) & '"' = "5"

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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