Results 1 to 7 of 7

Thread: How can I get the Command$?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    How can I get the Command$?

    I want to make my program load associated data when clicking on some document - i.e. some TBGL3dEd-image in win-explorer.
    I know from vb6 the command$ which returns the parameters that have been appended to filename when the app started. How can I get the "command$"-parameters so I know which file the user wants to open?

    And related to this/other way: Is there a possibility to detect if some filename from explorer was dragged + dropped into TBGL-window?


    Edit: First question is answered already- because after posting this- the related topic list on bottom did show the solution...I searched APP_.../Core and just "Command"

    OS_Command(s) now I've found, and also that I have to truncate CHR$(34) -"- from start and end of string before using it.

    But also found out something strange here: If I open a model from Explorer now, App_Scriptpath seems to get set to the path where the model is located and my script creates new Subfolders for Models, Textures and Undo inside the models path as if they were not present in App_Scriptpath. So textures won't load because scriptpath is wrong then.
    Last edited by ReneMiner; 18-04-2013 at 10:01.
    I think there are missing some Forum-sections as beta-testing and support

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

    OS_GetCommand behaves differentely when in thinAir and when the script is launched separately.

    Why?

    Because thinBASIC passes you the whole command line which the core interpreter receives.

    If you want to get the parameters relevant for you script only, I do it this way:
    Uses "OS"
    
    MsgBox 0, Script_Parameter(1) ' -- This should return the file name for you
    
    ' Description: Function returns nth parameter of the script
    ' -----------------------------------------------------------------------------
    ' Parameters:                                                                  
    ' -----------------------------------------------------------------------------
    ' index: index of nth parameter, starting from 1
    Function Script_Parameter( index As Long ) As String
      Long paramOffset = IIf(StartsWith(OS_GetCommand(0), "@"), 2, 1)  
      Function = OS_GetCommand(index+paramOffset)  
    End Function
    

    Petr
    Last edited by Petr Schreiber; 18-04-2013 at 10:12.
    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,530
    Rep Power
    171
    I did that way:

    OS_GetCommand(2) holds the models path + filename
    If OS_GetCommands >= 2 Then 
      sFileToLoad = Mid$(OS_GetCommand(2), 2, Len(OS_GetCommand(2)) - 2)
      Call_IfExists "LOAD_Model" + FILE_PathSplit(sFileToLoad, %PATH_EXT) (sFileToLoad) To bSuccess
    EndIf
    
    Made an exe from my project, rightclick in Explorer some modelfile - m15, obj or tbgl3ded - choose my exe to open it and the model gets loaded. All ok, works so far...
    BUT: App_Scriptpath - which gets accessed way before this call, contains/returns the path where the model is located then - but not the real App_Scriptpath where the script is located.
    The needed Subdirs of my script are not found inside the models path - why should they be there? - and get created here as if they were not present in App_Scriptpath. So the assumed Subfolders as Textures & Undo are empty - no texture gets loaded - unnecessary folders get created at wrong place - App_Scriptpath returns/contains a wrong value.

    My working-directories are wrong now since they get created inside the clicked models-path

    So I might return to second way: Is there some possibility to detect if some filename from Explorer was dragged & dropped into TBGL-Window?

    OT: @ Petr- got new system?
    Last edited by ReneMiner; 18-04-2013 at 11:12.
    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,

    regarding TBGL window and drag'n'drop - I think it should be achieveable now by using the EventShaper. There is no specific support for Win32 messages in TBGL as of now.

    The APP_ScriptPath behaviour is strange, it should work the same as in script. I will have a look.

    OT: Yes It is beautiful machine, with raw power up to 5x bigger (both CPU and GPU) than my Win7 notebook for the same price which the notebook cost 3 years ago. Incredible.


    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

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    Sorry, the EventShaper looks like a seven-sealed-book to me - too much win-specific - confusing stuff that I have no idea about - also it uses UI and callbacks which I don't have for my just-in-TBGL-window-app and I want to avoid callbacks anyway since they are not native to basic but some way to communicate with OS. I don't like being a slave to OS-rules and all those cumbersome methods - I want to use Basic-commands and -methods - that's why I did not create the app in UI-dialog and made my own controls - so not to have these "ugly beasts" and "alien-windows-variables" in my script.

    I don't know where to start with and how to find out the Path nor the Filename that was dropped into the window. Neither do I know, how to append some callback-functions to TBGL-window and how to register if it was a drag&drop-action. And just for this function the effort and needed resources seem way too high - I'd rather create some check-back for the App_Scriptpath - even if it would mean to save the correct path to some ini-file to "C:\" on the users system. That's not nice, I know - but it's a basic-way.

    Or should there an issue created about?
    Last edited by ReneMiner; 18-04-2013 at 18:36.
    I think there are missing some Forum-sections as beta-testing and support

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

    if APP_ScriptPath returns something else than script path... it is ideal candidate for issue. Failing example would help a lot.
    One possible temporary solution:
    Function Script_Path() As String
    
      Function = FILE_PathSplit(APP_ScriptFullName, %PATH_ROOTPATH)
    
    End Function
    
    Regarding EventShaper - I understand Could you please add a feature request for TBGL to accept dragged files?


    Petr
    Last edited by Petr Schreiber; 21-04-2013 at 14: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

  7. #7
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    I created an issue with some example-code attached.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. command$ to thinbasic ?
    By Lionheart008 in forum thinBasic General
    Replies: 4
    Last Post: 21-08-2010, 19:01
  2. windows nt command script
    By sandyrepope in forum Shout Box Area
    Replies: 2
    Last Post: 21-10-2007, 09:50
  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. Explorer command bar
    By ErosOlmi in forum Software discussion
    Replies: 0
    Last Post: 16-09-2006, 11:28

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
  •