Jump to content
Amixg

Unknown function in AutoIT

Recommended Posts

Amixg

Hi! I have another problem with AutoIT.  You see, I'm still the one who's just starting out with this great programming language. I have a problem with AutoIT, it seems not to recognize the "StringReplace" function even when it is by default. The code was made half in KODA and half of my own. It is a software programmed for the Italian language (I am Italian) and translate the SMS language into Italian correct. Would you help me? Thanks in advance.

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hull = "hello"
StringReplace($hull, "hello", "hellx")

$Form1 = GUICreate("Linguaggio SMS A Italiano", 507, 498, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 24, 40, 465, 177)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Inserisci qui il testo che non riesci a capire:", 24, 8, 205, 17)
$Label2 = GUICtrlCreateLabel("Ecco il testo tradotto(non toccare questo campo):", 27, 237, 237, 17)
$Edit2 = GUICtrlCreateEdit("", 24, 264, 465, 137)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Traduci", 104, 424, 249, 49)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
                Case $Button1
                     StringReplace(GUICtrlGetData($Label1), "qlc", "qualcuno")
                     StringReplace(GUICtrlGetData($Label1), "qls", "qualcosa")
                     StringReplace(GUICtrlGetData($Label1), "ke", "che")
                     StringReplace(GUICtrlGetData($Label1), "x", "per")
                     StringReplace(GUICtrlGetData($Label1), "pls", "per favore")
                     StringReplace(GUICtrlGetData($Label1), "tu6", "tu sei")
                     StringReplace(GUICtrlGetData($Label1), "zzz", "mi fai dormire")
                     StringReplace(GUICtrlGetData($Label1), "hagn", "Buonanotte")
                     StringReplace(GUICtrlGetData($Label1), "tvtb", "Ti voglio tanto bene")
                     StringReplace(GUICtrlGetData($Label1), "tat", "Ti amo tanto")
                     StringReplace(GUICtrlGetData($Label1), "lafs", "Amore a prima vista")
                     StringReplace(GUICtrlGetData($Label1), "fli?", "Flirtiamo?")
                     StringReplace(GUICtrlGetData($Label1), "msidt", "Mi sono innamorato di te")
                     StringReplace(GUICtrlGetData($Label1), "ba", "Bacio")
                     StringReplace(GUICtrlGetData($Label1), "midi", "Mi dispiace.")
                     StringReplace(GUICtrlGetData($Label1), "ntm", "Non ti merito")
                     StringReplace(GUICtrlGetData($Label1), "tdp", "Togliti dai piedi.")
                     StringReplace(GUICtrlGetData($Label1), "amò", "Amore")
                     StringReplace(GUICtrlGetData($Label1), "ap", "A presto!")
                     StringReplace(GUICtrlGetData($Label1), "cmq", "comunque")
                     StringReplace(GUICtrlGetData($Label1), "cvd", "Ci vediamo dopo")
                     StringReplace(GUICtrlGetData($Label1), "Tvb", "Ti voglio bene")
                     StringReplace(GUICtrlGetData($Label1), "nn", "non")
                     StringReplace(GUICtrlGetData($Label1), "risp", "rispondimi")
                     StringReplace(GUICtrlGetData($Label1), "cel", "cellulare")
                     StringReplace(GUICtrlGetData($Label1), "dom", "qualcosa")
                     StringReplace(GUICtrlGetData($Label1), "nm", "numero")
                     StringReplace(GUICtrlGetData($Label1), "fv", "favore")
                     StringReplace(GUICtrlGetData($Label1), "-male", "meno male")
                     StringReplace(GUICtrlGetData($Label1), "disc", "discoteca")
                     StringReplace(GUICtrlGetData($Label1), "se#", "settimana")
                     StringReplace(GUICtrlGetData($Label1), "+ o -", "più o meno")
                     StringReplace(GUICtrlGetData($Label1), "ts", "torno subito")
                     StringReplace(GUICtrlGetData($Label1), "tvtbcoa", "Ti voglio tanto bene come amica")
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
Au3Builder

there is no such thing as GuiCtrlGetData. I believe you meant GUICtrlRead.

Edited by Au3Builder
  • Like 1

Share this post


Link to post
Share on other sites
Amixg
3 minutes ago, Au3Builder said:

there is no such thing as GuiCtrlGetData. I believe you meant GUICtrlRead.

Thanks.  Strange, the error said that the error was in StringReplace. Thank you.

Share this post


Link to post
Share on other sites
Au3Builder

Press F1 in Scite to Open Help File.It contains a lot of useful information.

  • Like 1

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

  • Similar Content

    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • milos83
      By milos83
      Default keyword for optional parameter is interpreted wrongly.
      ConsoleWrite(StringReplace("aa", "a", "b", Default, 1) & @CRLF) StringReplace ( "string", "searchstring/start", "replacestring" [, occurrence = 0 [, casesense = 0]] ) The code above will output ab even thou the default value for the occurrence is 0 (replace all).
      Of course using zero instead of Default will work fine.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I was trying to insert function header to the functions of my script, but, in the SciTE console, this appears:
      Function or struct definition not found, unable to insert header. @Jos Any suggestion?
      Thanks in advance.

      Best Regards.
    • smartkey
      By smartkey
      Hi All,
           I have written a UDF for one of my requirement which replaces a single character in string with a sub string/another character. 
           I am using this for my requirement by calling below function as StrReplace("C:\Software\Autoit\Substr","\","\\") and gives result as C:\\Software\\Autoit\\Substr
           Please let me know if this can be improvised or any mistakes to correct.   
      ;===============================================================================
      ;
      ; Function Name:    StrReplace($INPUT_STRING)
      ; Description:      This function is to replace a character with another in a string.
      ; Parameter(s):     $INPUT_STRING     - Original String Value
      ;                    $STR_2_FIND     - Single Character to find the $INPUT_STRING
      ;                    $STR_2_REPLACE     - Substring/Multiple Characters to replace in place of     $STR_2_FIND value
      ; Requirement(s):   Replacing one single Character in a string with multiple Characters
      ; Return Value(s):  success - Output string after replacing a character with required character
      ;                    failure - 0
      ; Author(s):        smartkey
      ;
      ;===============================================================================
      Func StrReplace($INPUT_STRING, $STR_2_FIND, $STR_2_REPLACE)
          Local $OUTPUT_STRING = ""
          If StringLen($INPUT_STRING) > 0 Then
              If StringMid($INPUT_STRING,1,1) = $STR_2_FIND Then
                  $OUTPUT_STRING = $OUTPUT_STRING & $STR_2_REPLACE
              Else
                  $OUTPUT_STRING = StringMid($INPUT_STRING,1,1)
              EndIf
              For $i=2 to StringLen($INPUT_STRING)
                  If StringMid($INPUT_STRING,$i,1) = $STR_2_FIND Then
                      $OUTPUT_STRING= $OUTPUT_STRING & $STR_2_REPLACE
                  Else
                      $OUTPUT_STRING= $OUTPUT_STRING & StringMid($INPUT_STRING,$i,1)
                  EndIf
              Next
              Return $OUTPUT_STRING
          Else
              Return 0
          EndIf
      EndFunc
    • Karnalsyn
      By Karnalsyn
      As with a lot of programming, the less manual repetition done to achieve the same outcome...the better.
      I package programs for network deployment at the organization I work for. Sometimes these applications require verbose messaging to the user, and sometimes by special request we have to turn that off and deploy silently.
      The way I currently handle these 2 scenarios is this.
      I have a function that builds the splashwin display screen to variable size depending on message length, and displays the desired message to the end user.
      Then at each point throughout my script as I need to make the user aware of what is currently happening, I inject a splashwin function call with the unique message pertaining to that specific event. ie. "Installing Microsoft Office, please wait..."
      In effort to build a more universal script to handle any type of request submitted. I've incorporated a switch command of '/silent'
      If cmdlineraw detects the usage of that switch when the script is triggered it sets a variable flag, ie. $silent = "on"
      Then at every splashwin call I make, I'm prefixing it with an IF statement that checks for the flag, and then does NOT display the message if that flag is "on". Or does display it if its not. Has worked for me just fine. But while I grow my programming skills and look for more streamlined ways of handling areas I find myself creating repetition. I'm curious if I can relocate that flag check. Taking it out of every single splashwin call, and injecting it into the function itself.
      Example of how I currently display or hide the splashwin based on command line...
      If StringInStr($cmdlineraw, "/silent", 0) Then
          $SilentSwitch = "ON"
      EndIf
      If $SilentSwitch = "OFF" Then SplashWin($Uninstalling & $ProductInfo[1][0])
      Some scripts have dozens of those splashwin calls littered throughout, so Is this the best approach I can take already? Or as stated earlier, can I pull the IF statement away from the splashwin call. And left the function as a whole either activate or deactivate as a result of the command line check.
×