Results 1 to 7 of 7

Thread: enVar - simple module for handling of environment variables

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    enVar - simple module for handling of environment variables

    In case you need to work with environment variables, you might be interested in module named enVar.

    It is provided with full source code, unit tests and binaries here:
    https://github.com/petrSchreiber/thinBasic_enVar

    How to use
    Get the DLL from latest release.

    Copy the DLL to your thinBasic/Mod directory, you should be able to reference it then like:
    Uses "EnVar"
    
    Example of the syntax:
        ' -- Sets value of MyVariable to MyValue
        enVar_Set "MyVariable", "MyValue" 
    
        ' -- Retrieves the value of given variable
        String s = enVar_Get "MyVariable" 
    
        ' -- Returns comma separated list of environment variables
        String s = enVar_List 
    
        ' -- Returns list of environment variables, separated by user specified string
        String s = enVar_List(";") 
    
        ' -- Erases the specified variable
        enVar_Remove "MyVariable"
    
        ' -- Returns non-zero value in case the variable does exist
        enVar_Exists "MyVariable"
    
        ' -- Set a variable with comma separated values
       envVar_Set "MyCars", "Tesla Model S,Ferrari 512GT"
    
       Long nCars = envVar_GetItemCount "MyCars" ' -- Presumes comma, returns 2
       nCars = envVar_GetItemCount "MyCars", "," ' -- Separator specified explicitly, returns 2
    
       String firstCar  = envVar_GetItem "MyCars", ",", 1 ' -- Returns "Tesla Model S"
       String secondCar = envVar_GetItem "MyCars", ",", 2 ' -- Returns "Ferrari 512GT"
    
    Let me know if you need anything to be added.


    Petr
    Last edited by Petr Schreiber; 12-03-2016 at 20:10.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Updated the gitHub page with first release - it allows you to download just the module or even the sources, if you want.
    Link updated in the first post of this thread.


    Petr
    Last edited by Petr Schreiber; 22-08-2015 at 17:02.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    Think the EnVar(iables) could be of more use if there was an Index possible (array of certain variables)

    as
    EnVar_SetArray "Player", 1, "Petr"
    EnVar_SetArray "Player", 2, "Eros"
    '...
    Long lCurrent = 1
    String currentPlayerName = Envar_Get "player", lCurrent 
    String allPlayersNames = Envar_ListArray "player", $CRLF
    
    Last edited by ReneMiner; 23-08-2015 at 17:52.
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Rene,

    nice idea. System environment variables do not support arrays, but maybe the module could provide some kind of abstraction over it.
    I think the best would be via user defined item separator, what do you think?


    Petr
    Last edited by Petr Schreiber; 23-08-2015 at 18:14.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    New version of this library is available, download the module here:
    https://github.com/petrSchreiber/thi...s/tag/1.9.16.1

    I added support for storing and retrieving comma (but even other character) separated values.


    Petr
    Last edited by Petr Schreiber; 12-03-2016 at 20:11.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    hey thats great, unfortunately my life is not allowing me to get deeper into this. I wish i would have the time and the opportunity to concentrate more on TB- but you know- life is not always playing the cards as one wants it. Currently my place to live is burning but give me two or three months and i will be back in old strength
    I think there are missing some Forum-sections as beta-testing and support

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Rene,

    I wish you that all becomes resolved quickly and how you want it to be. You are our hero, we are looking forward impatiently to have you back!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. IniFile - module for INI file handling
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 6
    Last Post: 18-03-2016, 21:21
  2. Organini - simple module for INI files
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 11
    Last Post: 04-05-2015, 05:41
  3. Simple Variables
    By Charles Pegge in forum O2h Compiler
    Replies: 0
    Last Post: 17-03-2009, 15:47
  4. File handling in TBGL module
    By ErosOlmi in forum TBGL General
    Replies: 3
    Last Post: 22-02-2007, 00:18
  5. Module data handling
    By ErosOlmi in forum Statistics Module
    Replies: 0
    Last Post: 07-09-2006, 10:52

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
  •