473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

Jun 15 '07 #1
2 1357
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

<ri*******@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.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

Jun 15 '07 #2
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 "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/de...reflection.asp

Phill

Jun 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Ching | last post by:
Can I run pythonw with a script that takes command line arguments then launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and nothing happens. Nothing, as in I am immediately returned...
2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
0
by: January Smith | last post by:
When I run the code below after creating an Empty .Net type project and adding an Empty C++ file it always opens a command window before displaying the form. If I write a similar VB application by...
9
by: Atley | last post by:
I am looking for a way to run DOS-type commands from within a VB.net 2003 application. I also need to be able to answer questions (ie 'Are You Sure') that the command line may require. ...
2
by: Enrique Bustamante | last post by:
Casting arrays that works on watch and command window but not in code. My application is casting arrays in a way it should work. To test if I was doing something invalid, I wrote a test code that...
4
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
5
by: piradie | last post by:
Hello, I've been googling around, and looking into different webpages but couldn't find a clear response for the issue I need to resolve, so I was hoping any of you could give me an answer to my...
1
by: SilverGS | last post by:
I want to automatically open a Command Window from the Startup folder in Windows XP. right now after XP starts, I click on Start run, cmd and then when the command window is open I type in a bunch...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.