CobraCore.commandLineArgs is read-only.
Is there any way of modifying the list of arguments passed to the program?
Forums
Is there any way to modify the commandLineArgs array?
5 posts
• Page 1 of 1
Re: Is there any way to modify the commandLineArgs array?
The list you get back can be modified, but if you invoke the method again from somewhere else, you get a new list:
I just always assign it to a local anyway and then pass it around if I need to. Something like:
This also means that Foo().bar() can be reused in other ways because it takes an argument instead of using a global source. Also you can do this if you want to skip the program name:
HTH
get commandLineArgs as List<of String>
return List<of String>(Environment.getCommandLineArgs)
I just always assign it to a local anyway and then pass it around if I need to. Something like:
class Program
def main
args = CobraCore.commandLineArgs
for arg in args, print arg
Foo().bar(args)
class Foo
def bar(args as IList<of String>)
pass
This also means that Foo().bar() can be reused in other ways because it takes an argument instead of using a global source. Also you can do this if you want to skip the program name:
args = CobraCore.commandLineArgs[1:]
HTH
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Is there any way to modify the commandLineArgs array?
Oh, so there is no way to modify the original argument list? In Ruby I could do ARGV.clear and it would empty the command line arguments.
I realize this may not be the way to go, but I just wanted to know if it was possible
I realize this may not be the way to go, but I just wanted to know if it was possible
- Gameday
- Posts: 27
Re: Is there any way to modify the commandLineArgs array?
I don't think there is. The args originally come from the "Environment" class whose members are listed here:
http://msdn.microsoft.com/en-us/library/system.environment_members.aspx
But I don't see anything to clear them.
http://msdn.microsoft.com/en-us/library/system.environment_members.aspx
But I don't see anything to clear them.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Is there any way to modify the commandLineArgs array?
Yeah, I don't think in .NET there's any straight forward method of going about that. Now I'm curious though, why would you want to clear or modify the command line arguments?
- CodexArcanum
- Posts: 21
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 54 guests