Simple way to print out commands loaded via command.AddLine

Greeting Opi Comrades

I am trying to print out a command that has been added via the command.AddlLine method.
I have a method that works see DOpus output Ref 010-020. Fancy method using an enumerator.
I want a simpler way knowing that I only have a single command added and I have tried using the command.CommandList method but it is not working. See ref 010-030 below.
What am I doing wrong? I know the command.CommandList method returns a StringSet object.
This does not seem to be the way to do it.
Apart from the working enumerator method (Ref 010-020) is there a simpler way of printing out the single command that has been added?

Thanks as always

function OnClick(clickData)
	DOpus.Output("001-000 Start");
	var cmd = clickData.func.command
	cmd.AddLine("Clipboard SET AAAAAA");
	DOpus.Output(" 010-000 cmd.Linecount     = " + cmd.Linecount);

	for (var eSel = new Enumerator(cmd); !eSel.atEnd(); eSel.moveNext())
		DOpus.Output(" 010-020                 --> " + eSel.item());
	DOpus.Output(" 010-030  cmd.CommandList   : " + cmd.CommandList.count);


cmd.CommandList is the count of ALL DOpus commands.
You probably are looking for cmd.linecount

Thanks for reply @errante - you may have noticed cmd.linecount is outputted above and I get a single number 1 (one). I assumed that was the number of commands currently loaded?

Sorry, I misread your question. It seems you want to get the content of all the lines you added to cmd? I don't think that's possible, and since they are added manually, it doesn't seem to make much sense to me.
If you want to see how many lines you added to cmd, you can do it without the for, with cmd.linecount

1 Like

Yes that is correct. I want to check what I have loaded to make sure it is correct.
I think there is probably only one way that is enumerate and cmd object as above....
Thanks anyway

Ok, try this:

var cmd = DOpus.Create.Command();
cmd.AddLine("Clipboard SET AAAAAA");
if (cmd.linecount > 0)
	DOpus.Output(cmd.linecount + ": " + cmd[0]);

Printing the command before adding it is not an option? E.g.

var cmdLine = 'my clever Opus command';

I guess it is. I am just a bit paranoid that my command got loaded ok.
Esp with complex regex and escape keys for inverted commas etc.

What do you think DOpus.Output(cmdLine) will print?

cmd[0] outputs undefined

Am going with a little function as per below
Thanks all...

Try (0) instead of [0]

Sorted. that works... :slight_smile: