ne0trace Posted July 28, 2008 Share Posted July 28, 2008 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: expandcollapse popup#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 Link to comment Share on other sites More sharing options...
DMEE Posted July 28, 2008 Share Posted July 28, 2008 try to use $project = StringReplace ($project, " ", "-") In the beginning there was nothing and then even that exploded - anonymous Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2008 Moderators Share Posted July 28, 2008 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. Link to comment Share on other sites More sharing options...
ne0trace Posted July 28, 2008 Author Share Posted July 28, 2008 no did not work #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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2008 Moderators Share Posted July 28, 2008 no did not work #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 WEndDidn'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. Link to comment Share on other sites More sharing options...
ne0trace Posted July 28, 2008 Author Share Posted July 28, 2008 Such lovely words in the morning. 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2008 Moderators Share Posted July 28, 2008 (edited) Such lovely words in the morning. 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 FelixFull 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 July 28, 2008 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. Link to comment Share on other sites More sharing options...
ne0trace Posted July 28, 2008 Author Share Posted July 28, 2008 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 Link to comment Share on other sites More sharing options...
ne0trace Posted July 28, 2008 Author Share Posted July 28, 2008 Hey, great that's done the job. In all honesty I am not sure if I understood what I did wrong. Felix Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now