Using Find and Replace from a Command Line

Canvas supports a command-line interface to find and replace strings in Canvas files stored in either a CygNet APPS or BSS folder or a local folder. Be aware that there is no undo for find and replace. Make a backup of your files before editing. See other important notes here.

To find and replace a string in a Canvas file

  1. Open a Command Prompt window.
  2. Navigate to the directory where the Canvas application is installed, typically CygNet\Bin.
  3. Type the command using the syntax described below.

Usage

Canvas -Find=[FindString] -Replace=[ReplacementString] -Files=[File1;File2;File3] -Source=[BSS|Local] -Options=[Controls;Metadata;Screen;Script]

 

Note: Command-line commands are not case sensitive.

Parameters

All parameters require additional data; follow each parameter with "=additional data"; see usage and examples.

Parameter Required Description

-Find

Yes

Specify the string you want to find. Wrap multiple words in quotation marks.

Example

-Find="find this string"

-Replace

Yes

Specify the replacement string. Wrap multiple words in quotation marks.

Example

-Replace="replace with this string"

-Files

Yes

Specify the full path and file name of any file(s) you want to edit in a semi-colon separated list wrapped in quotation marks.

Do not use -Path to specify the path to a file. The presence of both -Path and -Files invalidates the command line.

Example

-Files="C:\temp\MyScreen1.can;C:\temp\MyScreen2.can;C:\temp\MyScreen3.can"

-Source

Yes

Specify the source type for the file you want to edit. Options include:

  • BSS — Indicates that the file is stored in a CygNet APPS or BSS folder
  • Local — Indicates that the file is stored in a local or network Windows file-system folder

Examples

-Source=BSS

-Source=Local

-Options

Yes

Specify where in the file you want to make the substitution. These options can be combined in any order; they can be separated with any separator (a semi-colon (;) or a pipe (|)) or no separator at all. Options include:

  • Controls — Find and replace any string found in a Canvas control property
  • Metadata — Find and replace any string found in a screen's Metadata
  • Screen — Find and replace any string found in a screen (or object) property
  • Script — Find and replace any string found in a screen's script

Examples

-Options=Controls;MetaData;Screen;Script

-Options=Controls|Screen|Script

-Options=Controls Screen Script

-Help

No

Displays a dialog box showing command-line usage. "help", "\help", "/help", and "?" are also valid.

The Command Line Usage dialog box will be displayed when any invalid options are typed at the command line.

Examples

canvas help

canvas.view help

canvas.view.lite help

canvas ?

canvas.view ?

canvas.view.lite ?

canvas /help

canvas.view /help

canvas.view.lite /help

Command-Line Usage

You can get user assistance for the relevant command-line options for Find and Replace.

Command-line help for Canvas

Type Canvas -Help at the command-line prompt to see usage tips

Examples

C:\CygNet\Bin>Canvas -Find=YYYYY -Replace=ZZZZZ -Files=C:\Canvas_Screens\MyScreen.can -Source=Local -Options=Controls;Screen;Script

 

C:\CygNet\Bin>Canvas -Find=YYYYY -Replace=ZZZZZ -Files=CYGDEMO.BSS\Canvas_Screens\MyScreen.can -Source=BSS -Options=Script Controls Screen

 

C:\CygNet\Bin>Canvas -Find=YYYYY -Replace=ZZZZZ -Files=C:\Canvas_Screens\MyScreen.can -Source=Local -Options=Metadata|Script

 

C:\CygNet\Bin>Canvas -Help

 

Note: You cannot combine the Find/Replace parameters and other Canvas command-line parameters in the same command line. But you could do a find and replace and then open the file on the next command line.