584,860 active members*
5,239 visitors online*
Register for free
Login
Results 1 to 15 of 15
  1. #1
    Join Date
    Mar 2017
    Posts
    1295

    [TNGv2] - Expr.txt

    Expt.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.

  2. #2
    Join Date
    Jun 2017
    Posts
    143

    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
    Join Date
    Mar 2017
    Posts
    1295

    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
    Join Date
    Mar 2017
    Posts
    1295

    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
    Join Date
    Jan 2022
    Posts
    107

    Re: [TNGv2] - Expr.txt

    Why???

    Expression function '#OnInit' removed!

    Expression function '#Loop' removed!

  6. #6
    Join Date
    Mar 2017
    Posts
    1295
    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
    Join Date
    Jan 2022
    Posts
    107

    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
    Join Date
    Mar 2017
    Posts
    1295

    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
    Join Date
    Jan 2022
    Posts
    107

    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
    Join Date
    Mar 2017
    Posts
    1295

    Re: [TNGv2] - Expr.txt

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

  11. #11
    Join Date
    Jan 2022
    Posts
    107

    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...

  12. #12

    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
    Join Date
    Mar 2017
    Posts
    1295

  14. #14
    Join Date
    Mar 2017
    Posts
    1295

    Re: [TNGv2] - Expr.txt

    @awpross

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

  15. #15
    Join Date
    Jan 2022
    Posts
    107

    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

Similar Threads

  1. TNGv2 for Mac OSX
    By tantemay in forum PlanetCNC
    Replies: 47
    Last Post: 08-24-2023, 07:12 PM
  2. [TNGv2] - 2019-11-08
    By PlanetCNC in forum PlanetCNC
    Replies: 0
    Last Post: 11-09-2019, 02:15 AM
  3. [TNGv2] - Files and folders
    By PlanetCNC in forum PlanetCNC
    Replies: 0
    Last Post: 11-02-2019, 10:46 PM
  4. [TNGv2] - 2019-10-28
    By PlanetCNC in forum PlanetCNC
    Replies: 0
    Last Post: 10-28-2019, 04:52 PM
  5. [TNGv2 - API]
    By PlanetCNC in forum PlanetCNC
    Replies: 0
    Last Post: 10-27-2019, 11:23 PM

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
  •