473,765 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Commandline Argument Array Help

I have the following code:

Dim MyStartupArgume nts() As String

MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs

UBound(MyStartu pArguments)
RomName = (MyStartupArgum ents(0).ToStrin g)
ParentName = (MyStartupArgum ents(1).ToStrin g)

If ParentName = "" Then
LookUp = RomName
Else
Answer = Len(ParentName)
LookUp = Microsoft.Visua lBasic.Right(Pa rentName, (Answer - 1))
End If

lpAppName = LookUp

The problem seems to be that sometimes there is one command line argument and sometimes there are two. If there are two, everything is alright. If there is just one I get an error when it reads the "ParentName " line. Do I need to somehow grab the arguments with a loop and keep checkin until something is nell? How would I do that?

Also, this is a tough program to debug in the GUI since it relies on command line arguments. Is there a way to send commandline arguments with the GUI for debugging so I can step through my code?

Thank you,
John
Nov 20 '05 #1
5 1914
"jcrouse" <an*******@disc ussions.microso ft.com> schrieb
I have the following code:

Dim MyStartupArgume nts() As String

MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs

UBound(MyStartu pArguments)
RomName = (MyStartupArgum ents(0).ToStrin g)
ParentName = (MyStartupArgum ents(1).ToStrin g)

If ParentName = "" Then
LookUp = RomName
Else
Answer = Len(ParentName)
LookUp = Microsoft.Visua lBasic.Right(Pa rentName, (Answer
- 1))
End If

lpAppName = LookUp

The problem seems to be that sometimes there is one command line
argument and sometimes there are two. If there are two, everything is
alright. If there is just one I get an error when it reads the
"ParentName " line. Do I need to somehow grab the arguments with a
loop and keep checkin until something is nell? How would I do that?

Check MyStartupArgume nts.Length.
Also, this is a tough program to debug in the GUI since it relies on
command line arguments. Is there a way to send commandline arguments
with the GUI for debugging so I can step through my code?


You mean within the IDE? Set the commandline arguments in the project
properties.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
JLW
You can go into the Assembly Properties, and under the DEBUG section, you
can tell it to pass command line args when the IDE executes the assembly.

The esiest way I've found of doing Command Line Args is use a module as your
startup and use Sub Main as follows:

Public Sub Main(ByVal args as String())

args is already a split array for you, so you can either deal with each
array member seperatly, but here's how I do it:

Public Sub Main(ByVal args as String())
Dim arg as String
For Each arg in args
Select Case arg
Case Is = "--arg1"
{put your code for Argument1 here}
Case Is = "--arg2"
{put your code for Argument2 here}
Case Is = "--help"
{put your code for commandline help here}
[Case Else 'Put this to force the use of Command Line
Switches/Arguments
{put your code for commandline help here}]
End Select
Next
End Sub

The "Case Else" is only if want the end-user to use command line swtiches.
I personally use Linux style switches, but you can easily change the "--" I
have above to "/".

HTH,
JLW
"jcrouse" <an*******@disc ussions.microso ft.com> wrote in message
news:3C******** *************** ***********@mic rosoft.com...
I have the following code:

Dim MyStartupArgume nts() As String

MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs

UBound(MyStartu pArguments)
RomName = (MyStartupArgum ents(0).ToStrin g)
ParentName = (MyStartupArgum ents(1).ToStrin g)

If ParentName = "" Then
LookUp = RomName
Else
Answer = Len(ParentName)
LookUp = Microsoft.Visua lBasic.Right(Pa rentName, (Answer - 1))
End If

lpAppName = LookUp

The problem seems to be that sometimes there is one command line argument and sometimes there are two. If there are two, everything is alright. If
there is just one I get an error when it reads the "ParentName " line. Do I
need to somehow grab the arguments with a loop and keep checkin until
something is nell? How would I do that?
Also, this is a tough program to debug in the GUI since it relies on command line arguments. Is there a way to send commandline arguments with
the GUI for debugging so I can step through my code?
Thank you,
John

Nov 20 '05 #3
* "=?Utf-8?B?amNyb3VzZQ= =?=" <an*******@disc ussions.microso ft.com> scripsit:
I have the following code:

Dim MyStartupArgume nts() As String

MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs

UBound(MyStartu pArguments)
???
RomName = (MyStartupArgum ents(0).ToStrin g)
'If MyStartupArgume nts.Length > 1 Then...'
ParentName = (MyStartupArgum ents(1).ToStrin g)

If ParentName = "" Then


.... 'If ParentName.Leng th = 0 Then...'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
"jcrouse" <an*******@disc ussions.microso ft.com> schrieb
Tell me more. Maybe an example?


Example for what?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
Check the length of MyStartupArgume nts - if it's 1 - then you only got 1
argument - and it's up to you how you want to handle it. If the length is
2 - then you're all set, you had 2 arguments passed in from the user. But
don't try to get the argument at index 1 - if there was only 1 argument, of
course that will always fail.

"jcrouse" <an*******@disc ussions.microso ft.com> wrote in message
news:3C******** *************** ***********@mic rosoft.com...
I have the following code:

Dim MyStartupArgume nts() As String

MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs

UBound(MyStartu pArguments)
RomName = (MyStartupArgum ents(0).ToStrin g)
ParentName = (MyStartupArgum ents(1).ToStrin g)

If ParentName = "" Then
LookUp = RomName
Else
Answer = Len(ParentName)
LookUp = Microsoft.Visua lBasic.Right(Pa rentName, (Answer - 1))
End If

lpAppName = LookUp

The problem seems to be that sometimes there is one command line argument and sometimes there are two. If there are two, everything is alright. If
there is just one I get an error when it reads the "ParentName " line. Do I
need to somehow grab the arguments with a loop and keep checkin until
something is nell? How would I do that?
Also, this is a tough program to debug in the GUI since it relies on command line arguments. Is there a way to send commandline arguments with
the GUI for debugging so I can step through my code?
Thank you,
John

Nov 20 '05 #6

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

Similar topics

2
2560
by: Alexander Gausa | last post by:
hi i want to start a php programm from commandline and pass some parameters to the programm. but the programm did not recognize the parameters. the commandline ist: php liste.php para1=one para2=two the source (list.php) .... echo $_request;
1
7676
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into the bottom of this email)
26
2833
by: Martin Jørgensen | last post by:
Hi, I'm learning C-programming. I have a program which I would like to modify so it takes arguments from the commandline. Let call the program: program.exe. Could somebody shortly explain how I get this behaviour: C:>program -help or C:>program -h printf("\nBla. bla. Here is some help and arguments\n").... etc.
3
1862
by: pemo | last post by:
Opinion please. The code below is an attempt at demonstrating commandline arg processing. I don't really like the repetitive use of ... if(!(*s)) { // Make sure we don't go out of bounds. //
0
2768
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. CBOE appears to keep your form query data in cookies, so this seemed like a good use of curl. Well, my script works just fine when run from the commandline. When accessed from my browser, it returns an empty string where the data should be....
3
1604
by: postindex | last post by:
Can I get whole commandline not only argument list. 1. When I command like this $ a.py filename 2. sys.argv is returns only argument list Is there a way to find out 'redirection' information. thank you for reading this
2
1661
by: Toby | last post by:
I'm trying to write a simple commandline wrapper: a script that runs another program as a child and relays unbuffered stdin and stdout to/from the child process, possibly filtering it. The usefulness of such a program lies in the filtering stage, in a possible integration with readline, or in other interface enhancements. Still, I'd like to discuss with you the unfiltered, unembellished version, because I'm not satisfied with it and...
3
3672
by: balakrishnan.dinesh | last post by:
hi frndz, As we know that, we can pass command line agrument for C using "scanf" commands, So as same as that, Is there any way to pass those commandline arguments through php code to C and process them. If there plz soon, or tel me any alternative for this Rgrds Dinesh..
1
4810
by: edmondsnake | last post by:
Dear all, I would like to ask questions about my VB.net program. The executable file of the program is called "PSP.exe" Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim commandline As String = Environment.CommandLine Dim myParam As String = "" For Each param As String In _ My.Application.CommandLineArgs If param = "-s" Then If...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.