Summary
- Grimport Language Documentation
- Installation of Grimport & Other Software
- Variables & Syntax
- Control Structures
- Extract data from a page
- Export Filtered Data
- Programming with Grimport Script Editor
- Crawler and Logs
- GRS, GRC & GRL
- Folder Organization
- Launch Options
- Cache
- Mistakes & Errors
- Connected services
- To Go Further
To Go Further
Good coding practices
Naming a variable correctly
The name of your variable should represent its content:
- Use clear names even if they are long.
If you need to create a variable of a quantity of items in stock, instead ofquantity, writequantity_in_stock - Follow a common naming convention.
- Use underscores (_) for variables consisting of multiple words, such as
number_of_cars,final_response, etc - You can also use the CamelCase notation for variables which consists of starting each word with a capital letter:
MyVariableWillBeWrittenLikeThis
- Use underscores (_) for variables consisting of multiple words, such as
- Use only alphanumeric characters and underscores... and no accents!
For example, writehello_1but nothello_#1 - Remember that variable names are case sensitive.
age,AgeandAGEare three different variables - Copy and paste variable or function names rather than rewriting them (avoids typos).
- Do not use the same name for two local variables in different blocks.
Code layout
To easily find your way around your code, it is advisable to make a good layout. Here are some tips:
- Put spaces after commas and space out multiple parentheses
phpBigCommand( functionNow("all_product", [id_categorie_product, global.get("references"), id_supplier, 3, "stock_to_0", true]) )Instead of:
phpBigCommand(functionNow("all_product",[id_categorie_product,global.get("references"),id_supplier,3,"stock_to_0",true])) - Indent the code correctly: within each block, use Tab (Shift+Tab for reverse)
- Uniformity of the blocks: the brace comes under the if/for/while and not at the end of the line
//We prefer to write if (condition) { ... } //instead of if (condition) { ... }For the
each, it is the same principle//We prefer to write cleanSelectAll("p").each { paragraphe-> .... } //instead of cleanSelectAll("p").each{ paragraphe-> .... } - and don't forget to use comments
❮ Previous