Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Line Arguments Tutorial

Status
Not open for further replies.

smash81

Programmer
Mar 12, 2001
88
0
0
KE
Dear all,
I have the following requirements for my application:
Currently there is a process which sends some text to a program on a PC. The program formats the text and generates a print out.
I have no access to the source code of the program which does the above. However, I can configure the stream to send the text to an application that I would like to develop.
The application would get the feed, and process it.

I was thinking that the way to achieve this would be through command line argument (CLA). I could be wrong.

I need advice on whether this would be the right approach in which case you could also advise on where I could access some tutorials on CLA.

In case my thinking is wrong please advise on how I could achieve this task.

Thank you.
 
How much text is there in your stream ?. I have no idea what a command line will take but I would guess its fairly restricted. To access command line text just use...

Dim TextStream As String
TextStream = Command()

I would guess that the easiest way to process moderate volumes of text would be to pass the stream to a file then start the VB application to process that file (see FreeFile, Open, Input#, Line Input#, Lock and Close commands).

Once you have the data you could use "automation" to drive WORD (which has hugely powerful formatting functions), or Excel if that were more suitable. While we are here that could also be done from within Word (Excel), rather than a separate VB application, although it is less flexible done like this. If you do not want to use Word then you can do lots in VB itself using rich text boxes or manually (if you really want control and the hassle of writing functionality that Word already has).

If (instead) you want to do the formatting on-the-fly then I'm out of my depth.

Boggg1
[bigglasses]
 
<The application would get the feed, and process it.

Can you elaborate a bit on what you mean by "process" it?

Thx

Bob
 
Bobrodes,
By process it I mean format it.
The feed that I am talking about is very sensitive and it would not be acceptable to have it save to a file before I run my program to do the formatting on it.
It has to be done on-the-fly.

An example of formatting could be
Feed coming in as :
{ABC Co Ltd}{Xyz Co Ltd}{USD10,000}

My program should format this to:
Paying Company : ABC Co Ltd
Receiving Co : Xyz Ltd
Amount : USD10,000
 
>However, I can configure the stream

Perhaps you can expand a little on this
 
Strongm
However, I can configure the stream

What i mean is that I can direct the stream to write into a text file or ,(if there's a VB solution for my problem) , go to my appliacation
 
OK, I'll be clearer.

What stream?
How do you direct it?

The answer to these will may make a significant contribution to deciding on a potential solution
 
The process flow is as under:
1) Some text is sent to the computer that I would like to use.
2) When the text arrives, it goes to a "redirector" application that directs the stream to another application which does the formatting and prints the formatted text.
3) The "redirector" can be configured to send the stream to various destinations like a text file for instance.

My application would have to get the text from step 2 as I cannot use the text file that is created. The reason for this is that, since the data is sensitive, someone could have tampered with the text file before my application picks the data.
So, what I would do is if I am able to create an application which can accept a text stream as it's input, then I would direct the text (at step 2) to my application.


Hope this helps. Please let me know if you need any further clarification.
 
Ok, that's more like it (and more along the lines of what I expected).

This isn't appropriate to a command line solution. What you want to be able to do is write to the STDIN of the VB program.

Only VB programs, by design, don't have a STDIN.

However, a quick search in this forum should find at least two techniques for adding STDIN back to a VB program and how to read it
 
Strongm,
Thank you very much for the idea. I'll try to read up on it and advise if it is going to be the solution I was looking for.

Thanks
 
Stongm,
Thanks for the tip. I have read up on STDIN. The challenge now it how to get my application to accept the text stream without typing the <application name><arguments>.
I would like my application to "listen" and accept any stream that comes in.
Is this possible.

Thanks once again.
 
Er ... you just get the redirector that you mentioned to redirect to the STDIN of your application. Your application would be listening on STDIN.

 
strongm,
Thank you for assisting me this far.
I have tried to get some programs from the internet that can do both STDOUT(to the STDIN program) and STDIN(from the STDOUT program) but i've not been able to tie the two to test the functionality. Since I am not good at programming of this kind. Please advise me on on where I could get some programs that could work for me to be able to learn from them

Once again Thanks a million
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top