DOpus.TabGroups' is null or not an object (0x800a138f)

Hi,
I want to write a simple button script that saves my tab groups.
According to the documentation, DOpus should have a property, either DOpus.TabGroups or DOpus.tabgroups, which should provide a .Save() method for that.
https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/TabGroups.htm
https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/DOpus.htm

But neither seems to exist.

function OnClick(clickData)
{
	DOpus.TabGroups.Save();
	DOpus.tabgroups.Save();
}

'DOpus.TabGroups' is null or not an object (0x800a138f)

What is going on, what am I missing?

Or in general, how do I best save the currently open tabs in my standard lister programmatically?
I want to prevent losing open tabs in the event of unexpected shutdowns or crashes. Sometimes when my system is unstable, I close and re-open DOpus, but that is a hassle; I'd much rather put it on a button or a timer.

Thank you

DOpus.TabGroups is a collection of multiple tab groups. The Save method has to be called on the individual group which you've made changes to.

The documentation states otherwise: The .Save() method is on the TabGroups collection, not on the individual TabGroup objects.

I tried it, but it failed:

var tabGroups = [];

	var c = 0;
	for (var menum = new Enumerator(DOpus.TabGroups); !menum.atEnd(); menum.moveNext()){
		tabGroups[c] = menum.item();
		var name = menum.item().name; // surely, if it did work, it would return a TabGroup item, not a TabGroups collection object of TabGroup
		DOpus.output(name); // This would be to check if we indeed have a TabGroup object - but of course, we don't get that far
		menum.item().Save();
		c++;
	}

Error at line 6, position 7 (Where the enumerator loop is defined)
Object not a collection (0x800a01c3)

It DID say that DOpus.TabGroups is not an object -- but then again, JS has problems with DOpus "objects" in general, so I don't know how true that is.

Am I enumerating it wrong? I know there are different methods, but the above usually works.

My mistake. I misread the docs earlier.

DOpus.TabGroups.Save(); doesn't produce an error for me, now I'm back at my PC, although I haven't been able to get it to do anything either.

This runs without error but has no real effect that I can see:

function OnClick(clickData)
{
	var g = DOpus.TabGroups.AddChildGroup("Test");
	g.desc = "Test desc";
	var tabs = g.tabs;
	tabs.AddTab("C:\\");
	DOpus.TabGroups.Save();
}

Jon should be able to answer this properly once his timezone is awake.

Huh, that's strange.
For me, the first line already throws the error.
I already do have saved/named tab groups, but the script doesn't seem to know the first thing about tab groups :confused:

The problem is that DOpus.TabGroups returns a new object each time. The tab group object you're adding the tab to isn't the one you're saving.

If you change it to only call TabGroups once then it should work:

	var grps = DOpus.TabGroups();
	var g = grps.AddChildGroup("Test333");
	g.desc = "Test desc";
	var tabs = g.tabs;
	tabs.AddTab("C:\\");
	grps.Save();
2 Likes

Hi Jon,

if I try to assign/call DOpus.TabGroups(), I get

Object doesn't support this property or method (0x800a01b6)

Of course I tried both property syntax and method syntax before, each with both CamelCase and lowercase names.

I've been restoring and saving settings since DOpus 9, I think - could that somehow result in something like this?
I still have artifacts from earlier versions: Some menu items still show up in German (I'm German and I used to have DO set to German - but I like English better and changed DO to English a few years back now)
Capture 2020-06-04 00-40-22 Capture 2020-06-04 00-40-11

It never bothered me, but now I'm wondering if that could be symptomatic of something bigger :thinking:

What's the best way to reset DO completely?
I thought the Backup/Restore menu might have an option for that, but it seems that's not the case

Menu items won't affect what a separate script does.

Only thing I can think of is that the button's script language is set to the wrong thing instead of JScript.

If you do want to reset your configuration for other reasons, uninstalling and then reinstalling will do that.

Well I know that - or rather, I would hope so!
Since I needed to start thinking outside the box, however, I thought maybe, since importing old settings could apparently overwrite what I imagined to be DO stock components, maybe some DO object definition was also overwritten with one that didn't have the .TabGroups member - really just crazy spitballing here, since I was at my wit's end.
Ugh, restart required - this'll take a while.

I don't think resetting your configuration will help.

Note that if the tab group you're trying to add already exists, Opus doesn't return an object for it - it returns false instead. Trying to then use that return value as an object would result in an error. Is that possibly what's happening?

If you run this code exactly as shown and make sure the tab group has a unique name, does it work? If not, what line is the error shown for?

var grps = DOpus.TabGroups();
var g = grps.AddChildGroup("Test2");
g.desc = "Test desc";
var tabs = g.tabs;
tabs.AddTab("C:\\");
grps.Save();
DOpus.Output("completed");

Going back to your original post:

You can do that by running the Go TABGROUPSAVE command, which doesn't even need scripting (or can be run from a script too). If all you want to do is save the tabs you currently have open then that's probably an easier solution.

1 Like

:confounded: :blush: :angry: :frowning_face:
(Sigh...)

So I removed DOpus and installed it fresh.
Tested the script, it worked.
Started recording video to document what happened when I imported my old settings.
Imported old settings and tested the script, fully expecting it not to work.
It. Worked.
Just like that.

I'm sorry to have wasted so much time and effort, but whatever was going wrong, re-installing DOpus seems to have fixed it.

And

is a beautiful cherry on top!

Thank you two for your time!

I'm updating the TabGroups Save documentation to make this clearer:

2 Likes