Loop inside a loop: @ifset: clause inside an @if: clause

I'm trying to run a loop inside a loop: an @ifset: clause inside an @if: clause so I can return to the original left or right dual file list after going to a single file display.

I'm misunderstanding something because the following code (blank lines for readability) never goes to a single file display. What should the code be/what am I misunderstanding?

@toggle:disable
Set PAIREDFOLDERS=off

@if:Set FOCUS=left

@ifset:DUAL=On
Go TABGROUPSAVE="!both,!closeall,DST"
Set DUAL=toggle,vert,remember
Toolbar "Operations Left" LOADSET=replace
@ifset:else
Set DUAL=toggle,vert,remember
Go TABGROUPLOAD="DST" TABCLOSEALL
Toolbar "Default" LOADSET=replace
Set FOCUS=left

@if:else

@ifset:DUAL=On
Set DUAL=toggle,vert,remember
Go TABGROUPSAVE="!both,!closeall,DST"
Toolbar "Operations Left" LOADSET=replace
@ifset:else
Set DUAL=toggle,vert,remember
Go TABGROUPLOAD="DST" TABCLOSEALL
Toolbar "Default" LOADSET=replace

Here's what I use as a toggle single/dual pane :

@toggle:if Set Dual=off
@if:Set DUAL=on
@set lst:sourceWasRight={=IsChecked("Set SOURCE=right")=}
Set DUAL=toggle,remember

@if:else
Set DUAL=toggle,remember
=return Val("$lst:sourceWasRight") ? "Go SWAP" : ""
=return Val("$lst:sourceWasRight") ? "Set SOURCE=right" : ""

If I remember correctly, it comes from this forum.

Those things don't nest. Once you need that much complexity, it's better to switch to a JScript button.

@PassThePeas

Several comments:

  1. Thank you for taking the time to respond with code. You saw that I was trying to create a toggle.
  2. Your code does toggle. It does not return to the original starting file display which was my goal with the looping business. It always ends up at the right file display.
  3. Removing from your code
    @set lst:sourceWasRight={=IsChecked("Set SOURCE=right")=} =return Val("$lst:sourceWasRight") ? "Go SWAP" : "" =return Val("$lst:sourceWasRight") ? "Set SOURCE=right" : ""
    does not change the results; it still toggles for me. What is it supposed to do.
  4. The following code does return to the original file display:
@toggle:if Set Dual=off
@if:Set DUAL=on
@set lst:sourceWasLeft={=IsChecked("Set SOURCE=left")=}
Go TABGROUPSAVE="!both,!closeall,DST"
Toolbar SAVESET=quiet NAME=Temp
Set DUAL=toggle

@if:else
Set DUAL=toggle
Toolbar "Temp" LOADSET=replace
Go TABGROUPLOAD="DST" TABCLOSEALL
//=return Val("$lst:sourceWasLeft") ? "Go SWAP" : ""
=return Val("$lst:sourceWasLeft") ? "Set Focus=left" : ""

For it to return to the original file display, two thing have to be used:

  1. a Toolbar pair has to be used, a dummy one here
  2. saving the original tabs and recalling them. Yes, I know the "remember" argument for Set DUAL remembers the tabs but using the tab pair is necessary to get the return to the original file display.

I don't understand why these are necessary but it works to return to the original file display.

I look forward to any comments might have.

I don't get it.
It does return to its original state for me.
When the right/bottom panel is the one you keep, then the collapsed one returns on right/bottom before they get switched.

Start in the left/top panel and run your code. I bet it returns to the right side of the dual lister. The problem is Opus returns to the right file display whether you started in the left or right file display. This is a longer standing behavior. I don't know any easy way to get around it.

There is a new code for Opus 13, Miscellaneous Commands [Directory Opus Manual]
Set SIDE= that the docs say tells you which file display you're in but I

  1. haven't seen any examples so I don't know how to use it and
  2. it only works for buttons in the Location Bar.

Look closer to the video, I do it both with top/left pane active, then with bottom/right active.

The active pane is the one with the blue location bar.

  1. The top/left is active, I click the button and the bottom disappears. Clicking again makes the bottom reappear at the bottom.
  2. I activate the bottom pane, then click the button. The top pane disappears, leaving the former bottom one the only visible. Clicking the button again make the bottom pane reappear with the content of the former top pane, then they are switched back to their original positions.

Is your button placed on a pane independent toolbar ? (meaning, not on the toolbar attached to the location bar)

EDIT: As a complement.

My understanding (since as stated, I did not write this button), is that that is the purpose of the first part of the button :

@toggle:if Set Dual=off
@if:Set DUAL=on
@set lst:sourceWasRight={=IsChecked("Set SOURCE=right")=}
Set DUAL=toggle,remember

Line by line

  • Activate toggle behavior
  • If we were on dual,
  • then stores in a lister variable (sourceWasRight) if the active pane was the right/bottom
  • then toggles to single, and remembers the tabs

And it's then checked on in the second part of the button code

@if:else
Set DUAL=toggle,remember
=return Val("$lst:sourceWasRight") ? "Go SWAP" : ""
=return Val("$lst:sourceWasRight") ? "Set SOURCE=right" : ""

Line by line

  • If we were not in dual mode
  • Sets back to DUAL (toggle, remember : restores the tabs)
  • Then we have two evaluator tests
    • If the variable sourceWasRight is set, then it means right is now left (due to the behavior you describe), so it executes GO SWAP to interchange the two panes
    • If the variable sourceWasRight is set, it executes Set SOURCE=right to give focus/activate the right pane.

Thanks for devoting your time to my issue. I found the problem!

Preference "Set new panel to when switching to dual file display" MUST be deselected. Your code then works just as you said.

Thanks for the walk through on the code.

I am greatly relieved. I've been futzing with this for a year. Thank you ever so much.

1 Like