Hi,
could someone help me with the syntax of SWITCHPATH please. I need to be able to switch between the current path and the current path with ~snapshot appended to it and back again with the same button.
i need something to this effect but I'm not sure exactly how to code it: Go PATH={s!} SWITCHPATH={s!}~snapshot GOBACK
In addition to this if its possilbe, it would be great if the switch only happened if the current/active folder {s!} started with a specified prefix, such as "C:\FOLDER", maybe even with a popup message when this condition isnt met.
To limit the button to a path, you can add [b]@ifpath:D:[/b] or similar to the top of the button code.
I had some tests with Go SWITCHPATH and also could not get it to work, but I think your GOBACK at the end is wrong in every case, it is not a valid option or switch for GO if I looked up that right.
Function OnClick(ByRef ClickData)
Set path = ClickData.Func.sourcetab.path
pathStart = UCase(path) & ""
parentFolder2 = UCase(ParentFolder) & ""
If (Left(pathStart, Len(parentFolder2)) = parentFolder2) Then
Set cmd = ClickData.Func.Command
If (UCase(path.filepart) = UCase(ChildFolder)) Then
cmd.RunCommand "Go UP BACK"
Else
childPath = path & "" & ChildFolder
If (DOpus.FSUtil.Exists(childPath)) Then
cmd.RunCommand "Go """ & childPath & """"
Else
ClickData.Func.Dlg.Request "No " & ChildFolder & " below here.", "OK", "Path switcher"
End If
End If
Else
ClickData.Func.Dlg.Request "Not below " & ParentFolder, "OK", "Path switcher"
End If
End Function[/code]
Thanks tbone for the introdction to the @ifpath command. Ive had some success with it.
Sadly leo, we are not yet using DOpus 11 otherwise I would be much more in my VB programming element.
Is it possible in Dopus 10 to expand on the @ifpath command. Remember, the challenge is to add ~snapshot when it doesnt exist and take it away when it does, but only when the prefix of the path is C:\FOLDER
I'm thinking regular expressions could achieve this but I havent used them before in Dopus. I'm thinking along the lines of this:
If the path starts with C:\FOLDER and ends with ~snapshot @ifpath:REGEXP ^C:\FOLDER(.*)~snapshot$
then PATH=PATH - "~snapshot"
Go PATH=REGEXP PATH (minus ~snapshot on the end)
If the path starts with C:\FOLDER and DOES NOT end with ~snapshot @ifpath:REGEXP ^C:\FOLDER(.*)~snapshot$
then PATH=PATH + "~snapshot" (this is the only bit that works) Go PATH={S!}~snapshot
Getting it to work with @ifpath will be difficult, if even possible, because you probably need nested conditions. (Unless there's some clever way to solve it using regexps with negative asserts, maybe.)
OTOH, using a script makes it trivial. This kind of thing is what scripting is for.
Ok gents. I appreciate the effort and understand completely. I've written a number of external scripts that I launch from Dopus to get what I need. I was hoping on this occasion Dopus 10 could address it internally.