Jump to content
Sign in to follow this  
ne0trace

Stringreplace and misunderstood concepts

Recommended Posts

ne0trace

Hello,

my topic might be a little misleading but I think that I did not quite understand the concept of stringreplace. Whenever I use a fix string, everything works fine. But as soon as I use a variable it's not working.

But see for yourself:

#include <GUIConstantsEx.au3>

GUICreate("nerve", 300, 300)
GUICtrlCreateLabel("Please select your option. Input might be disabled if needed!", 10, 10)
$sapphirebutton = GUICtrlCreateButton ("Activate/Sapphire", 30, 50, 100)
$trapcodebutton = GUICtrlCreateButton ("Activate/Trapcode", 180, 50, 100)
$wakeonlan = GUICtrlCreateButton ("Start/the/Farm", 105, 90, 100)
$customer = GUICtrlCreateInput ("Customer Code", 105, 160)
$project = GUICtrlCreateInput ("Project Name", 105, 190, 100)
$createdir = GUICtrlCreateButton ("Create Directory", 105, 230, 100)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $sapphirebutton
        Run ("\\work\administration\scripts_batchdateien\Sapphire_registrieren\plugin_sapphire_aktivieren.exe
")
;      MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg = $trapcodebutton
        Run ("\\work\administration\scripts_batchdateien\Trapcode_registrieren\Trapcode_registrieren.exe")

    Case $msg = $wakeonlan
        Run ("\\work\administration\scripts_batchdateien\FRA_wake_farm.bat")

    Case $msg = $createdir
    StringReplace ($project, " ", "-")
        $path = GuiCtrlRead($customer) & GuiCtrlRead($project)
        MsgBox (4096, "Test", $path)
       

    Case $msg = $GUI_EVENT_CLOSE
;      MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")


        ExitLoop
  EndSelect
WEnd

cheers Felix

Share this post


Link to post
Share on other sites
DMEE

try to use

$project = StringReplace ($project, " ", "-")


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites
SmOke_N

StringReplace (GUICtrlRead($project), " ", "-")


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
ne0trace

no did not work :P

#include <GUIConstantsEx.au3>

GUICreate("nerve", 300, 300)
GUICtrlCreateLabel("Please select your option. Input might be disabled if needed!", 10, 10)
$sapphirebutton = GUICtrlCreateButton ("Activate/Sapphire", 30, 50, 100)
$trapcodebutton = GUICtrlCreateButton ("Activate/Trapcode", 180, 50, 100)
$wakeonlan = GUICtrlCreateButton ("Start/the/Farm", 105, 90, 100)
$customer = GUICtrlCreateInput ("Customer Code", 105, 160)
$project = GUICtrlCreateInput ("Project Name", 105, 190, 100)
$createdir = GUICtrlCreateButton ("Create Directory", 105, 230, 100)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $sapphirebutton
        Run ("\\work\administration\scripts_batchdateien\Sapphire_registrieren\plugin_sapphire_aktivieren.exe")
;      MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg = $trapcodebutton
        Run ("\\work\administration\scripts_batchdateien\Trapcode_registrieren\Trapcode_registrieren.exe")

    Case $msg = $wakeonlan
        Run ("\\work\administration\scripts_batchdateien\FRA_wake_farm.bat")

    Case $msg = $createdir
    
$project = StringReplace ($project, " ", "-")
    $path = GuiCtrlRead ($customer) & "-" & GUICtrlRead ($project)
        MsgBox (4096, "Test", $path)
    Case $msg = $GUI_EVENT_CLOSE

        ExitLoop
  EndSelect
WEnd

Share this post


Link to post
Share on other sites
SmOke_N

no did not work :P

#include <GUIConstantsEx.au3>

GUICreate("nerve", 300, 300)
GUICtrlCreateLabel("Please select your option. Input might be disabled if needed!", 10, 10)
$sapphirebutton = GUICtrlCreateButton ("Activate/Sapphire", 30, 50, 100)
$trapcodebutton = GUICtrlCreateButton ("Activate/Trapcode", 180, 50, 100)
$wakeonlan = GUICtrlCreateButton ("Start/the/Farm", 105, 90, 100)
$customer = GUICtrlCreateInput ("Customer Code", 105, 160)
$project = GUICtrlCreateInput ("Project Name", 105, 190, 100)
$createdir = GUICtrlCreateButton ("Create Directory", 105, 230, 100)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $sapphirebutton
        Run ("\\work\administration\scripts_batchdateien\Sapphire_registrieren\plugin_sapphire_aktivieren.exe")
;      MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg = $trapcodebutton
        Run ("\\work\administration\scripts_batchdateien\Trapcode_registrieren\Trapcode_registrieren.exe")

    Case $msg = $wakeonlan
        Run ("\\work\administration\scripts_batchdateien\FRA_wake_farm.bat")

    Case $msg = $createdir
    
$project = StringReplace ($project, " ", "-")
    $path = GuiCtrlRead ($customer) & "-" & GUICtrlRead ($project)
        MsgBox (4096, "Test", $path)
    Case $msg = $GUI_EVENT_CLOSE

        ExitLoop
  EndSelect
WEnd
Didn't work? You didn't use it! (Unless you were talking about the other guys post.

Also, you're work is so garbled in the forum output, I'm going to assume you did some hack job on the script to post it there, but next time could you use Tidy in the SciTE editor before posting? Thanks...


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
ne0trace

Such lovely words in the morning. :P

I actually meant the first reply. But I just tried yours and it didn't work either. It still outputs the name with the spaces in the project name.

Regarding the Tidy option... I can't find it. I installed the very recent version of autoit+scite.

Thank you

Felix

Share this post


Link to post
Share on other sites
SmOke_N

Such lovely words in the morning. :P

I actually meant the first reply. But I just tried yours and it didn't work either. It still outputs the name with the spaces in the project name.

Regarding the Tidy option... I can't find it. I installed the very recent version of autoit+scite.

Thank you

Felix

Full Scite Download

I don't know what other help you could receive... I showed you that you were only using the control id of the control, and not reading the actual text value of it. As we have absolutely no idea what that input holds, you can receive no more helpful information.

Edit:

I see your mistake... you are changing $project from a Control to a String, then trying to use GUICtrlRead on a string when it is meant for a control... try this:

#include <GUIConstantsEx.au3>

GUICreate("nerve", 300, 300)
GUICtrlCreateLabel("Please select your option. Input might be disabled if needed!", 10, 10)
$sapphirebutton = GUICtrlCreateButton("Activate/Sapphire", 30, 50, 100)
$trapcodebutton = GUICtrlCreateButton("Activate/Trapcode", 180, 50, 100)
$wakeonlan = GUICtrlCreateButton("Start/the/Farm", 105, 90, 100)
$customer = GUICtrlCreateInput("Customer Code", 105, 160)
$project = GUICtrlCreateInput("Project Name", 105, 190, 100)
$createdir = GUICtrlCreateButton("Create Directory", 105, 230, 100)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $sapphirebutton
            Run("\\work\administration\scripts_batchdateien\Sapphire_registrieren\plugin_sapphire_aktivieren.exe")
            ;      MsgBox(0, "GUI Event", "You pressed OK!")
        Case $msg = $trapcodebutton
            Run("\\work\administration\scripts_batchdateien\Trapcode_registrieren\Trapcode_registrieren.exe")

        Case $msg = $wakeonlan
            Run("\\work\administration\scripts_batchdateien\FRA_wake_farm.bat")

        Case $msg = $createdir
            $path = GUICtrlRead($customer) & "-" & StringReplace(GUICtrlRead($project), " ", "-")
            MsgBox(4096, "Test", $path)
        Case $msg = $GUI_EVENT_CLOSE

            ExitLoop
    EndSelect
WEnd
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
ne0trace

Hello SmOke_N ,

the input right now doesn't seem to be the issue here. Whatever I try to put in the box (my name or the default entry of the field: "Project Name") the string doesn't replace anything. But whenever I use StringReplace ("something something", " ", "-") it works.

Felix

Share this post


Link to post
Share on other sites
ne0trace

Hey,

great that's done the job. In all honesty I am not sure if I understood what I did wrong.

Felix

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.