Command window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • risberg83@gmail.com

    Command window

    Hi

    I want to create a program that starts some kind of command window.
    The program should contain some functions and the user should be able
    to call these functions trough the command window. Eg. If I have a sub
    called hallo() that prints "hallo" in the command window, I want to be
    able to call it from the command window with some command like
    "hello()". Is this possible to do, and if it is what is the easiest
    way to do it?

    Thanks

    Johan

  • PlatinumBay

    #2
    Re: Command window

    One option you have is to create a Windows Console application, and set it's
    path in your Windows path variable. Then you just call it via it's filename
    (without the extension).

    I created a utility to GZip files, and I use it from the command prompt.

    C:\Documents and Settings\stevan ich>gzip
    Syntax:
    gzip "C:\somefile.tx t" "C:\somefile.gz "
    gzip "C:\somefile.gz " "C:\somefile.tx t" \u

    In this case though you are not calling a sub directly, rather the Main
    method on the assembly.

    If you want to invoke specific methods, your Main method needs to accept
    parameters, and then you decide what to do with the parameters, like call a
    specific method, ect.

    Hope this helps,


    Steve

    <risberg83@gmai l.comwrote in message
    news:1181869896 .598660.225930@ j4g2000prf.goog legroups.com...
    Hi
    >
    I want to create a program that starts some kind of command window.
    The program should contain some functions and the user should be able
    to call these functions trough the command window. Eg. If I have a sub
    called hallo() that prints "hallo" in the command window, I want to be
    able to call it from the command window with some command like
    "hello()". Is this possible to do, and if it is what is the easiest
    way to do it?
    >
    Thanks
    >
    Johan
    >

    Comment

    • Phillip Ross Taylor

      #3
      Re: Command window

      On Jun 15, 2:11 am, risber...@gmail .com wrote:
      Hi
      >
      I want to create a program that starts some kind of command window.
      The program should contain some functions and the user should be able
      to call these functions trough the command window. Eg. If I have a sub
      called hallo() that prints "hallo" in the command window, I want to be
      able to call it from the command window with some command like
      "hello()". Is this possible to do, and if it is what is the easiest
      way to do it?
      >
      Thanks
      >
      Johan
      This is the flat out easiest way to do it:

      public sub main

      read from console
      select (input)
      case "printHelloWorl d":
      printHelloWorld ()
      end select

      end sub

      public sub printHelloWorld ()
      'write hello world.
      end sub

      How ever you CAN inspect a class object and pull it's functions list,
      which you could optional print to screen, then invoke them later based
      on user choice or input. This technique is called "Reflection " (and
      dynamic type loading) but it's not for the faint hearted and requires
      a good understanding of Object Orientated development.

      Here's the MSDN reference to the Reflection classes.



      Phill

      Comment

      Working...