Command window

  • Thread starter Thread starter risberg83
  • Start date Start date
R

risberg83

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
 
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\stevanich>gzip
Syntax:
gzip "C:\somefile.txt" "C:\somefile.gz"
gzip "C:\somefile.gz" "C:\somefile.txt" \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
 
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 "printHelloWorld":
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.

http://msdn.microsoft.com/library/d...ry/en-us/cpref/html/frlrfsystemreflection.asp

Phill
 
Back
Top