More Info on Editing Advanced Functions Needed

Hi Everyone,

I'm trying to create a bit of general purpose "code" that I can paste into the "Advanced Section" of the Command Editor. I'd like to be able to "turn on" and "turn off" portions of the code based on what I need for the button. So here are the details ...

I'm executing Locate32 from a button and using its several command line switches to make it work for each type of button. For instance, I have a button that will excute Locate32 and populate the path switch with the current path of the active lister. I then pop-up a few dialog boxes asking for the name I want to find another one that asks if I want to find a file, folder, or either, etc. Here's the code I used for the 1st button I created:

cd "C:\Program Files (Portable)\locate32_x64"
C:\Program Files (Portable)\locate32_x64\locate32.exe -lfd -P0 -lcnm -lwn -lrn -r {dlgstring|Enter text to find in NAMED:}

After I realized all the different variations of the Locate32 app I could run, I whittled the variations to a handful of options I know I would use with some regularity. I know I want to find files by their name, sometimes by extension, sometimes by modified date, sometimes by size, and I always try to narrow the location(s) of my searches. I also want to use any combination of these parmeters for a search. But I want to predefine some buttons that focus on particular searches.

Rather than rewrite code for each button, I want write enough code once to cover all of the scenarios and simply turn on or off the parts of the code as I need them. To do this (and keep it simple), I thought I would use remarks and copy variables when and where I needed them. So here's my first attempt ...

[i][b]cd C:\Program Files (Portable)\locate32_x64

@set vFileFolder=-lfd
'@set vFileFolder={dlgchoose|Select what to LOOK FOR:|Files and Folders=-lfd+Files only=-lf+Folders only=-ld}

@set vMinSize=0
'@set vMinSize={dlgchoose|Select the minimum file size:|1KB+10KB+20KB+30KB+40KB+50KB+75KB+100KB+1MB+10MB+100MB+1000MB+2000MB+3000MB+4000MB+5000MB}
'-lm {$vMinSize}

@set vMaxSize=0
'@set vMaxSize={dlgchoose|Select the maximum file size:|10KB+20KB+30KB+40KB+50KB+75KB+100KB+1MB+10MB+100MB+1000MB+2000MB+3000MB+4000MB+5000MB+6000MB+7000MB+8000MB+9000MB+10000MB}
'-LM {$vMaxSize}

@set vPath=0
'@set vPath={dlgfolder|Select where to LOOK IN:|H:}

@set vNamed=
@set vNamed={dlgstring|Enter text to find in NAMED:}

@set vExt=
'@set vExt={dlgstring|Enter FILE Extension(s) to find (separate by spaces):}
'-t {$vExt}

@set vStartDate=
@set vStartDate={dlgstring|Enter the START DATE for a date range (YYMMDD):}

@set vEndDate=
@set vEndDate={dlgstring|Enter the END DATE for a date range (YYMMDD):}

@set vDaysOld=
'@set vDaysOld={dlgstring|Enter how many DAYS AGO the file was modified:}
'-lDmDAY {$vDaysOld}

@set vText=
'@set vText={dlgstring|Enter the TEXT found in the file:}
'-lc {$vText}

C:\Program Files (Portable)\locate32_x64\locate32.exe {$vFileFolder} -p{$vPath} -lDmDAY {$vStartDate} -lDMDAY {$vEndDate} -An -r {$vNamed}
[/b][/i]

You can see in the code above that I'm first initializing my variables with a @set varname=. I'm not even sure if this is right because I could not find this in the documentation anywhere. I want to initialize the variables and make sure they start out vallueless (null). Next I was hoping to use an apostophre (') to remark out statements. But that seems to work only to an extent. By this I mean that the statements that are remarked out don't appear to execute - at least I'm not prompted by those. But after I ran this code (Windows 7 Ultimate x64), I rec'd a "@set error":

  [Window Title]
  '@set

  [Content]
  Windows cannot find ''@set'. Make sure you typed the name correctly, and then try again.

  [OK]

I really don't know what's causing this error. I thought I would start by making sure I'm on the right track for syntax and how I'm trying to do this.

Any help with this would be greatly appreciated. Thank you,

RiteGuy

By the way, I attached a copy of Locate32's help page with all the command line switches.

A better way to do this is to create a User Command and give it a command template to allow you to pass arguments to it.

User Commands are created via Settings -> Customize -> Commands -> User.

After creating one you can call it from other buttons as if it was a built-in command.

Information on command templates (so you can make your User Command take arguments) is in the manual under Predefined Commands -> User - Predefined.

Thanks Leo, I'll take a look at that.

I guess I'm back to where I usually end up with DOpus - I'm never clear on how the details work and end up spending hours experimenting that sometimes produces results and other times leaves me frustrated. There's one page in the reference re: Predefined Commands -> User - Predefined. I consider it an overview of the topic. It mentions using "&& terminology" to specify that a parmeter from the command line is to be inserted into the function definition.

Where do I find the syntax for all this? I can define a template that has, let's say, 7 total parameters. I want to use that template in a button function that uses only 3 parameters. How do I map the calling function's parameters to the correct parameters in the template? I thought it may be by name, but the example doesn't work that way.

Is it positional? If so, how do I omit parameters I don't want to use or care about?

Is there a full blown syntax guide for these things in DOPus?

Thanks for your help ...

The page you refer to gives you an example. The "template" is a standard Opus command template, as described at the beginning of the "Opus Raw Commands" section of the manual. To specify where on the command line an argument is to be inserted, the &arg& syntax is used, where arg is the name you gave the argument in the template.