Giter Club home page Giter Club logo

tipps_and_tricks's Introduction

Tips & Tricks with AX Code

Snippets

Simple snippet example

{
    "comment_snippet": {
    "scope": "st",
    "prefix": ["comment, snippet"],
    "body": [
        "/// Block description 2",
        "/// $(1|place here the comment of method)",
        "/// Return value: $2",
        "${name:default}"
    ],
    "description": "Add an Comment;"
    }
}

Result:

snippet1

Loop snippet

{
    "loop":
    {
        "prefix": ["loop"],
        "scope": "st",
        "body":[
            "VAR_TEMP",
            "\t index : ${1|INT,LINT|};",
            "END_VAR",
            "FOR index :=  ${1|INT,LINT|}#${2|0,1,X|} TO ${3:EndValue} DO",
            "\t;",
            "END_FOR;"
        ],
    "description": "create a loop section with VAR_TEMP;"
    }
}

Result:

snippet2

Import global variables

Importing global variables into the VAR_EXTERNAL section of a POU

import

Format ST code

format

Documentation

Currently not productive; it might not always work

Documentation link

docu-link

Further information: Documentation Link

Inline Documentation

In SIMATIC AX you can add comments to your methods or functions with ///

inline-doc

Nice shortcuts

A complete overview of the shortcuts in VS Code/AX Coce you'll find here: VS Code shortcuts

Add selection to next Find match (CTRL+D)

ctrl_d

Insert cursor (Alt+Click)

alt_click

Search & Replace with Regex

regex

Useful search&replace patterns when you want to migrate SCL Code (exported from TIA Portal) into ST:

Search field Replace field Example
Remove all # for variables of a SCL source #([A-Za-z]) $1 #statVariable --> statVariable
Remove all { S7_SetPoint := 'False' ... } {[A-Za-z0-9 :=';_.]*} Bin2 { S7_SetPoint := 'False'} : "typeStatisticsBin"; --> Bin2 : "typeStatisticsBin"
Remove "name" "([A-Za-z]*)" $1
TIA-Type to ST-Type TYPE "([A-Za-z0-9_]*)" TYPE $1 :
Remove " in type declaration "([A-Za-z0-9_]*)" $1

thats's not a migration guide and it's still manual necessary. But it can make the life easier.

Further information

AX Code Documentation

Documentation Link

VS Code Documentation

Snippets collection on GitHub

PLC Open templates

Markdownlint-cli

This workspace will be checked by the markdownlint-cli (there is also documented ho to install the tool) tool in the CI workflow automatically.
To avoid, that the CI workflow fails because of the markdown linter, you can check all markdown files locally by running the markdownlint with:

markdownlint **/*.md --fix

License and Legal information

Please read the Legal information

tipps_and_tricks's People

Contributors

sjuergen avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

zantiu

tipps_and_tricks's Issues

SurroundWith code snippets

Describe the solution you'd like
A clear and concise description of what you want to happen.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.