Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/11/2012 in all areas

  1. Melba23

    _MemoryOpen/Writte

    ileandros, Well, the risk of that happening on this forum is now very likely if you ever post anything that even hints of game automation again. M23
    1 point
  2. Mat

    Memory release?

    I asked this question on stacoverflow a year ago: http://stackoverflow.com/questions/8604633/correct-way-return-a-string-from-a-function
    1 point
  3. ileandros

    Edit Text

    Change the tittle of the topic to "Write the code for me" #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> #include <File.au3> Global $language[3] Global $test[3] GuiCreate("Example",150,305) GuiCtrlCreateLabel("Name", 5, 20) $Name = GUICtrlCreateInput("", 35, 15, 75, 25) GuiCtrlCreateLabel("Age", 5, 60) $Age = GUICtrlCreateInput("", 35, 55, 75, 25) GUICtrlCreateLabel("Languages", 15, 100) $language[0] = GUICtrlCreateCheckbox("English", 15, 120) $language[1] = GUICtrlCreateCheckbox("Spanish", 15, 140) $language[2] = GUICtrlCreateCheckbox("Portuguese", 15, 160) $START = GUICtrlCreateButton("Start", 35, 225, 75, 25) GuiSetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Start _Modiffy() EndSwitch WEnd Func _Modiffy() Local $open = FileOpen("text.txt",1) $file = FileRead("text.txt") $str = "Hello, my name is Alberto, and i have 60 years old. I can speak spanish, and portuguese" If StringInStr($file,$str) Then $aSplit_String = StringSplit($str, " ") $New_String = "" $New_Name = GUICtrlRead($Name) $New_Age = GUICtrlRead($Age) $aSplit_String[5] = $New_Name $aSplit_String[9] = $New_Age For $i = 1 To $aSplit_String[0] ;number of elements in array $New_String &= $aSplit_String[$i] & " " Next _FileWriteToLine("text.txt",3,"Sed tristique. " & $New_String,1) EndIf EndFunc
    1 point
  4. ileandros

    Edit Text

    #include <GUIConstantsEx.au3> #include <EditConstants.au3> Global $language[3] Global $test[3] GuiCreate("Example",150,305) GuiCtrlCreateLabel("Name", 5, 20) $Name = GUICtrlCreateInput("", 35, 15, 75, 25) GuiCtrlCreateLabel("Age", 5, 60) $Age = GUICtrlCreateInput("", 35, 55, 75, 25) GUICtrlCreateLabel("Languages", 15, 100) $language[0] = GUICtrlCreateCheckbox("English", 15, 120) $language[1] = GUICtrlCreateCheckbox("Spanish", 15, 140) $language[2] = GUICtrlCreateCheckbox("Portuguese", 15, 160) $START = GUICtrlCreateButton("Start", 35, 225, 75, 25) GuiSetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Start _Modiffy() EndSwitch WEnd Func _Modiffy() $file = FileRead("text.txt") $str = "Hello, my name is Alberto, and i have 60 years old. I can speak spanish, and portuguese" If StringInStr($file,$str) Then $aSplit_String = StringSplit($str, " ") $New_String = "" $New_Name = GUICtrlRead($Name) $New_Age = GUICtrlRead($Age) $aSplit_String[5] = $New_Name $aSplit_String[9] = $New_Age For $i = 1 To $aSplit_String[0] ;number of elements in array $New_String &= $aSplit_String[$i] & " " Next MsgBox(0,"New String", $New_String) EndIf EndFunc As for the languages use a case statement cuz there are a lot of possibilities Edit: Changed it making it easier to understand i think. But there are a lot of ways to do it anyway
    1 point
  5. I actually (mostly) like J&#097;v&#097;script as a language, ignoring the confusing web-browser stuff. I'm personally like writing code using anonymous and nested functions, closures, etc. It's very far from perfect though: the (lack of) a class system makes object-oriented programming much harder than it should be (that's one of the reasons CoffeeScript and other languages that compile to JS are getting popular), the weak typing system causes unexpected gotchas and weird behavior (I'm not even talking about the lack of static typing: Python has completely dynamic typing, but blows up whenever you try to mix up incompatible types instead of giving you retarded results), the (lack of proper) scoping is a mind-boggling oversight, etc. CoffeeScript is the name of the language you mention. Most of it translates in a straight-forward way to vanilla J&#097;v&#097;script: most of the converted code I see doesn't look as bad as this example. I wonder if it was actually bad CoffeeScript to begin with.
    1 point
  6. JohnOne

    Edit Text

    There are many ways to do what you want to, depending on what functions you are comfortable with. here is a start example using an array, you will notice that name is always element 5 etc.. #Include <Array.au3> $Original_String = "Hello, my name is Alberto, and i have 60 years old. I can speak spanish, and portuguese." $New_String = "" $aSplit_String = StringSplit($Original_String, " ") _ArrayDisplay($aSplit_String) ; just for debug $New_Name = "Freddy" $aSplit_String[5] = $New_Name For $i = 1 To $aSplit_String[0] ;number of elements in array $New_String &= $aSplit_String[$i] & " " Next ConsoleWrite($New_String & @LF) You can remove, add, or replace elements of the array depending on what, and how many checkboxes are true, that's just logic.
    1 point
  7. Danyfirex

    Edit Text

    Remember you can use FileRead to load the text into a variable.
    1 point
  8. ileandros

    Edit Text

    $string="Hello, my name is Alberto, and i have 60 years old. I can speak spanish, and portuguese." $nameinput = GUICtrlCreateInput("",100,50) Local $text = StringReplace($string, "Alberto", GUICtrlRead($nameinput)) ;This is for the name ;You can do this for all the things you want to change MsgBox(0, "The number of replacements done was", $text)
    1 point
  9. Danyfirex

    Edit Text

    If you always know the name could use something like this. $string="Hello, my name is Alberto, and i have 60 years old. I can speak spanish, and portuguese." Local $text = StringReplace($string, "Alberto", "Danyfirex") Local $numreplacements = @extended MsgBox(0, "New string is", $text) MsgBox(0, "The number of replacements done was", $numreplacements)
    1 point
  10. Hi, A quick reply because someone is maybe building you a snippet of what you want : Split the file into words, then go through words and add them into an array if they have not been added yet, otherwise increment the subindex. Br, FireFox.
    1 point
  11. This example code will add a public folder to the public folder favorites. You then can add this public folder favorite to the folder favorites as shown in the mail module of the navigation pane (that's another piece of code I'm currently testing). #include <OutlookEX.au3> $oOL = _OL_Open() $aOL_Folder = _OL_FolderAccess($oOL, "Here you enter the folderpath to the public folder you need to access") If @error <> 0 Then Exit MsgBox(16,"Outlook Script", "Error accessing the public folder. Error: " & @error) $aOL_Folder[1].AddToPFFavorites If @error <> 0 Then Exit MsgBox(16,"Outlook Script", "Error adding folder to public folder favorites. Error: " & @error) _OL_Close($oOL)
    1 point
×
×
  • Create New...