Jump to content

Need help with Multivariable


Recommended Posts

I want to write a script that read thing in a textbox and use the text to calculate  "a2  " but instead of reading only one number, i want the script to read several numbers seperated by semicolon ";" or  comma "," and show the result by execute the script with each numbers sequentially . This is the example script:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            Equation(GUICtrlRead($Input1))
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc


 

Link to comment
Share on other sites

  • Developers

Something like this:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

3 minutes ago, Jos said:

Something like this:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

Thank you very much. I have a script with a bigger input box but my text is alway show on first line. I want it to auto word wrap (like word) but i don't know how to do. Can you help me again pls?

Link to comment
Share on other sites

  • Developers

Sure, that shouldn't be that difficult:

#include <EditConstants.au3>

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateEdit("a", 88, 42, 120, 60,$ES_MULTILINE)
Global $Solve = GUICtrlCreateButton("Solve", 160, 112, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

PS:No need to qoute my post as we can see what I wrote already ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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