VB.net 2003 - Converting a GUI-ed App into a Command-Line App

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sitko
    New Member
    • Sep 2007
    • 140

    VB.net 2003 - Converting a GUI-ed App into a Command-Line App

    Hi,

    I'm just starting an effort of converting a couple GUI front ended apps into Command line apps. Can anyone give me the conceptual process to go about this?
    Code:
    Public Class Form1
       Inherits System.Windows.Forms.Form
    
       Public Shared Sub Main (ByVal args() As String)
          'Do stuff
       end sub
    end class
    Sub Questions:
    - I'm assuming that I'll come up with an arbitrary ordering of the GUI inputs, so that the new program will look something like "CommandApp .exe Var1 Var2, ..."; is this a good assumption?
    - How would a Listbox (on the GUI) be converted to a command line argument? Would each line be a new argument, or is there some character I'd place to seperate the variables?

    Thanks,
    Sitko.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Originally posted by sitko
    Hi,

    I'm just starting an effort of converting a couple GUI front ended apps into Command line apps. Can anyone give me the conceptual process to go about this?
    Code:
    Public Class Form1
       Inherits System.Windows.Forms.Form
    
       Public Shared Sub Main (ByVal args() As String)
          'Do stuff
       end sub
    end class
    Sub Questions:
    - I'm assuming that I'll come up with an arbitrary ordering of the GUI inputs, so that the new program will look something like "CommandApp .exe Var1 Var2, ..."; is this a good assumption?
    - How would a Listbox (on the GUI) be converted to a command line argument? Would each line be a new argument, or is there some character I'd place to seperate the variables?

    Thanks,
    Sitko.
    There are two ways a command line application can get input from the user. First you can pass a list of params when the user invokes the exe. (ie myProgram.exe /a /b /c param1 param2 param3) The other way is to get input from the user after a prompt. If you have a complex gui you will likely have to use a combination of these techniques. As for a listbox, you app will need to print out a list of items that would normally appear in the listbox then ask they user to select one from the list.

    Comment

    • sitko
      New Member
      • Sep 2007
      • 140

      #3
      Originally posted by RedSon
      There are two ways a command line application can get input from the user. First you can pass a list of params when the user invokes the exe. (ie myProgram.exe /a /b /c param1 param2 param3) The other way is to get input from the user after a prompt. If you have a complex gui you will likely have to use a combination of these techniques. As for a listbox, you app will need to print out a list of items that would normally appear in the listbox then ask they user to select one from the list.
      Actually, I need to make the entire app command line driven, there is no interactivity options in this situation. The listbox will contain a list of files to access, not a choicelist where the user picks one from that list.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        Originally posted by sitko
        Actually, I need to make the entire app command line driven, there is no interactivity options in this situation. The listbox will contain a list of files to access, not a choicelist where the user picks one from that list.
        A command line can still be interactive. If it is such a thing where once the exe is started there can be no user interaction, then all inputs must be given at the time the exe is first started. So if you have some kind of choice that can be made in the gui, the user must make that choice before hand.

        Comment

        • sitko
          New Member
          • Sep 2007
          • 140

          #5
          Originally posted by RedSon
          A command line can still be interactive. If it is such a thing where once the exe is started there can be no user interaction, then all inputs must be given at the time the exe is first started. So if you have some kind of choice that can be made in the gui, the user must make that choice before hand.
          Yeah, my current thinking is to create a textfile with all the GUI elements inputs in it, and then read it in in the program, at runtime.

          We're converting this to sit behind some third party encapsulation system. Where the user will open up that apps "thin client", to put some of the inputs in, that app will create the text file, which would be fed to the VB.net app, sitting behind the scene.

          Any tips or thoughts would be appreciated as this is the first time I've done something like this, and if anyone had any "watchouts! " that would be very cool.

          Thanks,
          Sitko.

          Comment

          • RedSon
            Recognized Expert Expert
            • Jan 2007
            • 4980

            #6
            Originally posted by sitko
            Yeah, my current thinking is to create a textfile with all the GUI elements inputs in it, and then read it in in the program, at runtime.

            We're converting this to sit behind some third party encapsulation system. Where the user will open up that apps "thin client", to put some of the inputs in, that app will create the text file, which would be fed to the VB.net app, sitting behind the scene.

            Any tips or thoughts would be appreciated as this is the first time I've done something like this, and if anyone had any "watchouts! " that would be very cool.

            Thanks,
            Sitko.
            If you are going to be redesigning an application anyway you might want to consider changing your entire design paradigm. If you are looking to write an interface to your design then it sounds like you are trying to create a Model-View-Controller.

            It might help if you made this design goal formal for your project. Here is some more information about it. http://en.wikipedia.org/wiki/Model-view-controller

            Comment

            • sitko
              New Member
              • Sep 2007
              • 140

              #7
              Originally posted by RedSon
              If you are going to be redesigning an application anyway you might want to consider changing your entire design paradigm. If you are looking to write an interface to your design then it sounds like you are trying to create a Model-View-Controller.

              It might help if you made this design goal formal for your project. Here is some more information about it. http://en.wikipedia.org/wiki/Model-view-controller
              That does look like what were doing. The third party framework in this case is called EASA, you can check them out at: http://www.easasoftware.com/

              Unfortunately, I can't start from scratch, I need to use the VB.net app as is, and convert it to commandLine-ish format.

              I going through the code right now and converting all the references to txtboxes, or other GUI items to variables. Assuming that there will be a input text file, and assuming I have to use this app as a framework, do I just create the variables, comment out all the GUI bits, and create a Load_Data subroutine which loads the variables at the beginning of the app?

              Thanks,
              Sitko.

              ps. it helps me to just run stuff by people even if I think I've figured something out...thanks for being a sounding board... :)

              Comment

              • RedSon
                Recognized Expert Expert
                • Jan 2007
                • 4980

                #8
                Originally posted by sitko
                I going through the code right now and converting all the references to txtboxes, or other GUI items to variables. Assuming that there will be a input text file, and assuming I have to use this app as a framework, do I just create the variables, comment out all the GUI bits, and create a Load_Data subroutine which loads the variables at the beginning of the app?

                Thanks,
                Sitko.

                ps. it helps me to just run stuff by people even if I think I've figured something out...thanks for being a sounding board... :)
                Yea, I mean, I guess that sounds like a good solution. That is if you can determine all the inputs before you run the application. If you have access to the source why can you not just take all the parts out that you need and start an MVC project with them? That way you will be able to put any type of view you want to on it: GUI, command line, touch pad, mouse movements, morse codes, DTMF tones, anything really.

                Comment

                • sitko
                  New Member
                  • Sep 2007
                  • 140

                  #9
                  Originally posted by RedSon
                  Yea, I mean, I guess that sounds like a good solution. That is if you can determine all the inputs before you run the application. If you have access to the source why can you not just take all the parts out that you need and start an MVC project with them? That way you will be able to put any type of view you want to on it: GUI, command line, touch pad, mouse movements, morse codes, DTMF tones, anything really.
                  Sorry to ask a dumb question, but what is MVC? Microsoft Visual C(++)?

                  Comment

                  • RedSon
                    Recognized Expert Expert
                    • Jan 2007
                    • 4980

                    #10
                    Originally posted by sitko
                    Sorry to ask a dumb question, but what is MVC? Microsoft Visual C(++)?

                    Comment

                    Working...