Create Variables in Loop

  • I am taking lines from a .txt file and for each line I want to create a Global Variable so I can use it in threads.

    For example - File contains these 3 words:


    I want to make a loop where I can create global variable with name and value like this:

    global_var1 = walk
    global_var2 = fast
    global_var3 = now

    P.S- I don't want to use database and I need it dynamic, I don't want to define how many words are in the file. I am creating variables according to the number of words dynamically.
    I thought about using a list but list is not available in threads. I wanted to use 1 list in several threads but that's not possible it seems.

    Any help will be appreciated.

  • Might be that you just need to use special function
    "OnAplicationStart" You can create a list or do anything
    you need. Such function executes only once before any
    other action in script. So you could create a resource or
    set global variables or whatever suits you best.

  • This post is deleted!

  • @GaG
    Using function is not the problem but naming the variables seems to be the problem.

    How can I assign names like var1, var2, var3 dynamically?
    Refer to this screenshot -

  • You should describe your task in details.

    You can store these 3 words in resource and use it in
    any thread you want, no need for global variables.

    For example if you have TXT file with words, than you can
    just link it to resource and use in any thread. Thats why
    "resources" exists, so its prepared for you to use.

  • @hippyzipp9

    There are also spintax functions in BAS if you
    need to change order of words or want it make
    work randomly etc.

  • @GaG
    Sorry for not explaining clearly, here's what I am trying to do.
    I am taking .txt file as a resource that contains random words, they can be 5 or 10. If they contain 5 words I want to create 5 global variable likewise if they are 10 I want to create 10 global variables so that I can use global variables as a counter.
    Now when I use my bot in threaded mode, if thread 1 uses word1 then I want to increase the global counter of word1 but to do that I am unable to create dynamic global variables so that I can link each of them to my individual words in the .txt file.

    I hope I am clear now?

  • Any solutions? @Fox @support

  • You can use "Result" variables that are predefined in BAS. There are 9 of them.
    If you need more you can use filesystem actions and create TXT or CSV files
    to store any number you need. Similar to that you can use database for such
    tasks too.