Question About IF statements?

Support
  • Heyo!
    Im doing a BAS, and trying to see if this can work.
    Get Element Text, [[Saved_Text]]
    Log [[Saved_Text]] ,

    IF [[Saved_Text]] == "Thank you"
    Log Success
    Else
    Log Fail

    Is that something BAS can do? Ive been trying to do it for the past couple of weeks, and its looking like its not doing it properly. Like i will match it up to the log, and it will still do the else function.

    Any help?

    Thanks So Much!!

  • Ofcourse its possible, and its easiest and essential functionality.

    The trouble with your example is most likely the very first action
    that you are doing - "Get Element Text, [[Saved_Text]]".

    Internal bas log will show [[Saved_Text]] variable as "Thank you",
    but sometimes that variable might be slightly different, it can contain
    an emty line or empty (space) character or multiple of those, and it wont
    be visible in internal log.

    So you probably have to clean that varible by removing all that
    unwanted garbage left from original web page. You can do it with
    trim() and other javascript cleaning functions, or do it with BAS cubes
    meant for that, which are located under the "String" module as
    actions "Trim" and "Clean".

    Furthermore, to see how your original string looks like you should
    do some temporrary actions, that you can delete from script after
    determination. You should save variable [[Saved_Text]] to a TXT file
    with "Filesystem" module, action "Write File". Than open that newly
    created TXT file and you will see if it has any empty characters or even
    empty lines or anything else.

    This is just my prediction of what you are facing with. It would be
    much easier to help if you posted example script or exact web site
    from which you are gathering data.

  • @GaG you can save the text and use contain function, so you just use if [[CONTAINS]] "thank you".
    This is a bit easier I think

  • BASPremium Question

    Support
    0 Votes
    4 Posts
    486 Views
  • HTTPCLIENT question

    Support
    0 Votes
    5 Posts
    821 Views
  • External browser question

    Support
    0 Votes
    2 Posts
    575 Views
  • 1 Votes
    1 Posts
    684 Views
  • 0 Votes
    9 Posts
    2675 Views