idTech4.idCmdArgs.Get C# (CSharp) Method

Get() public method

Gets the argument at the specified index.
public Get ( int idx ) : string
idx int
return string
		public string Get(int idx)
		{
			if((idx >= 0) && (idx < _args.Length))
			{
				return _args[idx];
			}

			return string.Empty;
		}

Same methods

idCmdArgs::Get ( int start, int end ) : string
idCmdArgs::Get ( int start, int end, bool escapeArgs ) : string

Usage Example

Example #1
0
        private void ListByFlags(idCmdArgs args, CommandFlags flags)
        {
            string match = string.Empty;
            List <CommandDefinition> cmdList = new List <CommandDefinition>();

            if (args.Length > 1)
            {
                match = args.Get(1, -1).Replace(" ", "");
            }

            foreach (KeyValuePair <string, CommandDefinition> kvp in _commands)
            {
                if ((kvp.Value.Flags & flags) == 0)
                {
                    continue;
                }

                if ((match.Length > 0) && (kvp.Value.Name.StartsWith(match) == false))
                {
                    continue;
                }

                cmdList.Add(kvp.Value);
            }

            cmdList.Sort((a, b) => a.Description.CompareTo(b.Description));

            foreach (CommandDefinition cmd in cmdList)
            {
                idConsole.WriteLine(" {0} {1}", cmd.Name.PadRight(21, ' '), cmd.Description);
            }

            idConsole.WriteLine("{0} commands", cmdList.Count);
        }
All Usage Examples Of idTech4.idCmdArgs::Get