Results 1 to 7 of 7

Thread: help for tom :)

  1. #1
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    52
    Posts
    944
    Rep Power
    111

    help for tom :)

    hello new year 2010
    hello dear thinbasic users and tom

    here a little thinbasic example with "eval" module. never used it before, but seem to work. tom asked me last evening about this thing so I am sure it helps for 5 cents

    [code=thinbasic]'-------------------------------------------------
    'testcode for inputbox with evaluation by franko for tomLebowski
    '-------------------------------------------------

    Uses "eval", "ui"

    DIM Prompt AS STRING VALUE = "Enter Some thing here"
    Dim Title As String Value = "InputBox Example"
    Dim DefaultText As String Value = "press keyboard keys to change me"
    Dim myMsg As String Value = ""
    Dim UserExpression As String Value = ""

    Eval_SetNumber("6+8*15/4",0)
    UserExpression = InputBox$("Enter an expression",, "6+8*15/4") 'not 52,5 ! correct 36 !
    MsgBox 0, Eval_Math(UserExpression) '-36

    myMsg += UserExpression & $CRLF

    MsgBox 0, myMsg
    [/code]

    that's what I can do for the moment, I will check another, longer way without "eval" module. nice day, frank lionheart
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Re: help for tom :)

    Hi Frank,

    I'm sorry but this is not a correct example because Eval_SetNumber is not used in the correct way.
    Please read manual (well, maybe I have to improve it): Eval_SetNumber creates a variable in the Eval environment.
    So a typical usage could be Eval_SetNumber("MyVariable", 1234)

    Check examples in \thinBasic\SampleScripts\Eval\

    Here a possible correct example:
    [code=thinbasic]
    Uses "eval"

    Dim Prompt As String Value = "Enter Some thing here"
    Dim Title As String Value = "InputBox Example"
    Dim DefaultText As String Value = "press keyboard keys to change me"
    Dim UserExpression As String
    Dim Result As Ext

    '---Creates an Eval variable to be used in expressions
    Eval_SetNumber("MyDivider", 4)

    '---Ask for a math expression to be evaluated (here you can use your created variables)
    UserExpression = InputBox$("Enter an expression",, "6+8*15/MyDivider")

    '---Evaluate the expression
    Result = Eval_Math(UserExpression)

    '---Show result
    MsgBox 0, "Result of " & UserExpression & " is:" & _
    $CRLF(2) & Result
    [/code]

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    52
    Posts
    944
    Rep Power
    111

    Re: help for tom :)

    hi eros, that's correct, thanks for explanations. Have checked only short the manual

    [code=thinbasic]' Empty GUI script created on 01-04-2010 16:57:31 by (ThinAIR)

    Uses "eval","console"

    Dim Prompt As String Value = "Enter Some thing here"
    Dim Title As String Value = "InputBox Example"
    Dim DefaultText As String Value = "press keyboard keys to change me"
    Dim UserExpression As String
    Dim Result As Ext

    '---Creates an Eval variable to be used in expressions
    Eval_SetNumber("MySillys", 6)

    '---Ask for a math expression to be evaluated (here you can use your created variables)
    UserExpression = InputBox$("Enter a new expression!",, "6+8*15-12*8/MySillys") '110

    '---Evaluate the expression
    Result = Eval_Math(UserExpression)

    '---Show result
    MsgBox 0, "Result of " & UserExpression & " is:" & _
    $CRLF(2) & Result


    '-------------- manual help info:
    'Eval_SetNumber Define a numeric variable To be used Inside
    'Eval Function. If
    'variable already exists only its Value will change.
    '
    'n = Eval_SetNumber(VariableName, VariableValue)
    '---------------manual help end :
    [/code]

    I have this little but nice behaviour in my mind

    thanks, frank
    @eros
    ps: a) it's a secret that this "eval_math" expression is only a simple function or more ?
    b) it's possible to create with your re-writing new "thinair" to add a simple similar
    InputBox$ command like "Input" syntax for callbacks, functions and these cases?
    I don't know if it's possible.
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Re: help for tom :)

    Quote Originally Posted by Lionheart008
    a) it's a secret that this "eval_math" expression is only a simple function or more ?
    Eval_Math is a function able to solve whatever complex math expression not just simple one. Expressions can have also variables defined.
    Eval module is in reality a little BASIC inside thinBasic.
    Eval module have a lot of possibilities: you can define variables, you can link Eval variables to thinBasic script variables (but only dynamic strings or EXT numeric variables), you get get or set variables values in/out from Eval module.
    If interested, I can create more clever examples other than the one present in thinBasic.

    Quote Originally Posted by Lionheart008
    b) it's possible to create with your re-writing new "thinair" to add a simple similar
    InputBox$ command like "Input" syntax for callbacks, functions and these cases?
    I don't know if it's possible.
    Sorry Franck but I do not understand what you mean.
    Can you give me more info?
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5

    Re: help for tom :)

    hi frank, hi eros, many thanks for help. I have looked for a simple Inputbox with math. function, but didn`t know there is an own thinbasic "eval" module thank you both! I wanted to start for inputbox$ with function for calculate some values, so you have done in your previous examples.

    tom asked me last evening about this thing so I am sure it helps for 5 cents Wink
    I will send my idea if I am ready. thought also there were for console own "input" command or something like "?". for gui I should write own function, I see (without using eval module, so I can learn more!).
    sorry, have a lot of stress at the moment, my son is ill ;( thank for the tipp and the 5 cents ! best regards, great to get fast reply! tom

    ps: thanks for canvas help too!

  6. #6
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    52
    Posts
    944
    Rep Power
    111

    Re: callback input / help for tom :)

    good morning,

    because I find it useful to show how simple input with callback function does work here a little example for calculation of a plane (x,y) for example.

    plane calculation:
    [code=thinbasic]' Empty GUI script created on 01-05-2010 08:48:42 by franko (ThinAIR)
    '---------------------------------------------------------------------
    Uses "console", "ui"

    %LabelOne = 101
    %LabelTwo = 102
    %LabelThree = 103
    %LabelFour = 104
    %textboxy2 = 105
    %textboxy1 = 106
    %textboxy3 = 107
    %ButtonOne = 108

    Function TBMAIN () As Long

    Local hDlg As Long
    Dialog New 0, "PlaneCalculation",-1,-1,320,190,%WS_SYSMENU To hDlg
    Control Add Label, hDlg, %LabelOne, _
    "calculation of plane for rectangle:", 15, 15, 355, 10
    Control Add Label, hDlg, %LabelTwo, "lenght", 15, 50, 50, 10
    Control Add Textbox, hDlg, %textboxy1, " ", 75, 45, 80, 13, _
    %WS_TABSTOP Or %WS_BORDER Or %ES_NUMBER, %WS_EX_CLIENTEDGE
    Control Add Label, hDlg, %LabelThree, "width", 15, 80, 50, 10
    Control Add Textbox, hDlg, %textboxy2, " ", 75, 75, 80, 13, _
    %WS_TABSTOP Or %WS_BORDER Or %ES_NUMBER, %WS_EX_CLIENTEDGE
    Control Add Label, hDlg, %LabelFour, "planeResult", 15, 110, 50, 10
    Control Add Textbox, hDlg, %textboxy3, " ", 75, 105, 80, 13, _
    %WS_TABSTOP Or %WS_BORDER Or %ES_READONLY, %WS_EX_CLIENTEDGE
    Control Add Button, hDlg, %ButtonOne, "Calculation",195,104,105,15
    Control Add Button, hDlg, %IDCANCEL, "endClose",195,134,105,15
    Dialog Show Modal hDlg, Call DlgProc

    End Function

    CallBack Function DlgProc()
    Local txt As String
    Local a, b, c As Long

    Select Case CBMSG
    Case %WM_COMMAND

    Select Case CBCTL
    Case %ButtonOne
    If CBCTLMSG = %BN_CLICKED Or CBCTLMSG = 1 Then
    Control Get Text CBHNDL, %textboxy1 To txt
    a = Val(txt)
    Control Get Text CBHNDL, %textboxy2 To txt
    b=Val(txt)
    c = a*b
    Control Set Text CBHNDL, %textboxy3, Str$(c)
    End If
    Function = 1

    Case %IDCANCEL
    If CBCTLMSG = %BN_CLICKED Or CBCTLMSG = 1 Then
    Dialog End CBHNDL
    End If
    Function = 1
    End Select
    End Select
    End Function
    [/code]

    may be it's not 100 per cent perfect (I am not a superb callback profi!), but it works

    nice day, servus, frank
    Attached Images Attached Images
    Attached Files Attached Files
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  7. #7

    Re: help for tom :)

    thanks frank again. exactly that was I am looking for. simple gui with input and callback. I have written some example some years ago with c++, not very difficult. so I see it`s quite easy programming with thinbasic. I like this young and fast programming language! And I see the advantage of modules. as young teacher it takes longer to know all new things around thinbasic language, but then I am running fast and furious for a long time
    cheerio, tom

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •