top of page
Search

SCL code snippets

  • Writer: Ivaylo Fiziev
    Ivaylo Fiziev
  • Apr 25
  • 2 min read

Snippets are standard across programming languages. They are small portions of text that can easily be inserted while you type. The text follows the syntax of the target language. They speed up the development and also help you with the language grammar when you are a newbie.

Usually the development environment of use offers built-in snippets for the language control statements. Users can also create their own snippets for boilerplate code that they often have to write over and over again.


In Process Simulate SCL snippets are placed under the installation folder: ..\EmPower\Scripting\SCL\Snippets. All snippets have the .snippet file extension. They are regular UTF-8 encoded text files containing only the statements that are part of the snippet.

Example:


WHILE...DO.snippet

	WHILE #_variable_name_ > 0 DO
	    // statements
	    ;
	END_WHILE;

When inserted into the program text the code will be validated and any grammar/semantic errors will be reported. The user is expected to fix the errors before running the script. In this particular case the name of the variable will be invalid. When creating a snippet it is important that you come up with unlikely identifiers (if you have to use any). Otherwise you may get unexpected behavior when running the code. 

Snippets appear as regular auto complete candidates for the statements. The file names are used for the list. When you pick one, the body of the snippet will be inserted and a validation will be automatically triggered.


We provide SCL snippets for the common language constructs OOTB (conditional statements, loops, regions). Another common use case could be inserting copyright comments:

Basically any repetitive code can be treated like a snippet.

Some time ago in a post related to Scripting and OLP (https://ifiziev.wixsite.com/psinside/post/scripting-and-olp) I introduced the idea of having native robot snippets. Now you see it happening for SCL. For robotic languages snippets will be equally helpful. No obscure XMLs. Just plain text and a good parser.


I believe snippets will have a positive effect on the usability of SCL. They make the script more appealing to customers. Version 2509 will have it.


Happy typing!

 
 
 

4 Kommentare

Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
Benjamin Volzke
Benjamin Volzke
30. Apr.
Mit 3 von 5 Sternen bewertet.

Hi Ivo,

It's nice to see that things are moving forward with the SCL functions, but unfortunately I have to say that many things are OK but the basics are simply missing. Why don't you start a survey on what is really needed?


1. color highlighting

2. search

3. sorting

4. zooming

5. click / selection behavior

Gefällt mir
Ivaylo Fiziev
Ivaylo Fiziev
01. Mai
Antwort an

You can Copy/Paste the code to/from Notepad using the buttons on the toolbar. I will discuss the idea about the button with the team.

Gefällt mir

Subscribe Form

Thanks for submitting!

bottom of page