[TNGv2] - Expr.txt

Results 1 to 15 of 15

Thread: [TNGv2] - Expr.txt

  1. #1
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default [TNGv2] - Expr.txt

    Expr.txt file is inside profile folder. It is useful for simple scripts that need to be run periodically. It is executed on every screen refresh. Each line is single expression statement.

    Here is an example of Expr.txt with two expressions (two lines). First line checks if controller is connected. If it is not then "_concheck" parameter in increased and status line is updated. Second line checks if "_concheck" parameter is greater then 100. It it is then command "Reconnect" is executed, status is cleared and parameter is set to zero.

    To test this example put Expr.txt file to profile folder and restart TNGv2. Unplug USB cable from controller and observe status line. Then plug USB back to controller and controller will be reconnected then parameter counts to 100.

    Similar Threads:
    Attached Files Attached Files
    Last edited by PlanetCNC; 11-25-2019 at 03:30 AM.


  2. #2
    Member theRat's Avatar
    Join Date
    Jun 2017
    Location
    Australia
    Posts
    143
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    This looks pretty cool. Just wondering if there is a way to query an I2C device using this? I'm thinking about if it is possible to monitor some external sensor (ie. air pressure) and have them displayed within TNG. I am not sure how useful this would be, but it might be cool to be able to pause a program if the available air for cooling dropped below a certain pressure and resume when the compressor recharges. Doing that would probably cause different problems, but it's just a thought about what this might be useful for.



  3. #3
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    I2C is G-code command. You can not execute g-code command while your program is running.
    There is more elegant solution using USB expansion feature. For start take a look at Arduino example included in API. I will create another one with your scenario in mind for next Friday release.



  4. #4
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    Multiple Expr.txt files are now supported. Naming scheme is same as with state files. (Expr1_BlahBlah.txt, Expr2_Aloha.txt, ...)

    OnInit and OnShutdown sections are are now supported. Example:

    #OnInit
    print('OnInit')


    #OnShutdown
    print('OnShutdown')



  5. #5
    Member awpross's Avatar
    Join Date
    Jan 2022
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    Why???

    Expression function '#OnInit' removed!

    Expression function '#Loop' removed!



  6. #6
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default

    If there is an error in evaluation, function is removed and will not be evaluated again.
    You need to fix error in script.



  7. #7
    Member awpross's Avatar
    Join Date
    Jan 2022
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    OK, now a ; is required after each expression. How should I know this?? Even your examples don't use ; after each expression.

    And what is about Multiple Expr.txt files?
    Does not seem as if they are executed right now.

    I shoud mention that each Expr... file may contain the same sections like #OnInit or #Loop
    That worked until now. But currently, I can't see them working.



  8. #8
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    ; was always required. However in one line expressions it is automatically added. But because multiline expressions are now supported it is nod added automatically to every line now.

    Multiple Expr files are supported.
    Main one is "Expr.txt", others should use naming like this "Expr_myfunctions.txt",
    If you have functions with same name (eg #OnInit) in multiple files then all of them are executed.



  9. #9
    Member awpross's Avatar
    Join Date
    Jan 2022
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    Quote Originally Posted by PlanetCNC View Post
    Main one is "Expr.txt", others should use naming like this "Expr_myfunctions.txt",
    .
    So the naming convention has changed?
    Last time it was like this:
    Expr.txt
    Expr1_myFunc.txt
    Expr2_myOtherFunc.txt



  10. #10
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    I made number optional but it should still work I'll check what went wrong.



  11. #11
    Member awpross's Avatar
    Join Date
    Jan 2022
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    I meanwhile created a custom language in Notepad++ to be able to callapse sections and added all expressions to the expr.txt file.

    With the support of multiline, this is very cool.

    I hope ; is a good choice for comments. For now it is working.

    See attachment...

    Attached Thumbnails Attached Thumbnails [TNGv2] - Expr.txt-screenshot-2022-05-30-193358-png  


  12. #12
    Member jackandcoke's Avatar
    Join Date
    Feb 2019
    Location
    Mumbai
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    @PlanetCNC, can you update the list of events that are supported/available as callbacks? I have seen a couple of events being used in examples "#On_Serial_Event", "#OnUsbGamepad", etc that aren't included anywhere in the documentation.



  13. #13


  14. #14
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1295
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    @awpross

    Can you post your language definition? Perhaps on your github?

    Last edited by PlanetCNC; 05-19-2023 at 07:30 AM.


  15. #15
    Member awpross's Avatar
    Join Date
    Jan 2022
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default Re: [TNGv2] - Expr.txt

    I just uploaded th UDL definition for Notepad++ for the expr.txt files to https://github.com/styletronix/Plane...pad++%20Syntax



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

[TNGv2] - Expr.txt

[TNGv2] - Expr.txt