Results 1 to 3 of 3

Thread: How to command line arguments in Thinbasic ?

  1. #1
    Member
    Join Date
    Aug 2015
    Location
    Keralam, India
    Posts
    120
    Rep Power
    18

    How to command line arguments in Thinbasic ?

    Hi all,
    I need to get the cmd line arguments in my script.
    OS_GetCommand(1)
    
    This is not working. Please help. Thanks in advance.

  2. #2
    Member
    Join Date
    Aug 2015
    Location
    Keralam, India
    Posts
    120
    Rep Power
    18

    Cool

    I found the answer.
    First, I experimented with OS_GetCommand at the middle of my script. Then I paste the code to start of the script and it worked. But It dosen't catch the string inside quotes. For example,
    Assume that these are command line args
    SampleText1 "Sample Sample Sample text2"
    I need thinbasic to extract this a 2 commands.
    1. SampleText1
    2. "Sample Sample Sample text2"

    But thinbasic is extracting this args like this.
    1. SampleText1
    2. "Sample
    See. It stopped reading when the first space occurrance.
    I can't use OS_CommandsSetSep here.

    Edit "---------------------------------------------"
    ThinBasic saved me again.
    I use this to solve the problem
    Dim FullCmd as String = OS_GetCommand(0)
    Dim WorkingDir As String = GRAB$(FullCmd, Chr$(34), Chr$(34))
    
    So I get the proper string. Thanks.
    Last edited by kcvinu; 04-05-2021 at 16:52.

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,089
    Blog Entries
    5
    Rep Power
    725
    Hello,

    by default, thinBasic uses the following chars as separators:
    double quote, space, equal, minus

    To solve your case, you can go the following way:
    uses "os", "console"
    
    
    OS_CommandsSetSep(" ") ' Force just space to be a separator
    
    
    long i
    for i = 1 to os_getcommands
      printl OS_GetCommand(i)
    next
    
    
    waitkey
    
    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. Help: command line parameters
    By chliu in forum thinBasic General
    Replies: 4
    Last Post: 08-03-2012, 03:42
  2. how to extended a command to the next line
    By efly2020 in forum thinBasic General
    Replies: 5
    Last Post: 17-09-2008, 08:11
  3. CAD command line
    By Petr Schreiber in forum Real world situations and solutions using thinBasic
    Replies: 3
    Last Post: 13-10-2007, 21:03
  4. thinbasic command line?
    By sandyrepope in forum thinBasic General
    Replies: 4
    Last Post: 02-08-2007, 04:29

Posting Permissions

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