News:

  • April 24, 2026, 09:40:50 AM

Login with username, password and session length

Author Topic: Bug Repot: Cannot copy paste tasks or import from text file possible, need help  (Read 90 times)

Bobby Tables

  • Newbie
  • *
  • Posts: 3
When trying to copy paste or import tasks I get the following errors that appear to disallow users to import them.

This seems like a bug, why would this not be allowed when programs are allowed for import and export? Perhaps the import check has a bug. Either way it is impeding progress on an important project and I would very much appreciate any help on this issue.
I tried copy pasting a full task

DMD version: 2.11.2

when copy pasting these are the errors
[Error]      No logic inserted at eventlogger2#1
[Error]      Instruction "$TSK" cannot be inserted as a user instruction
[Error]      Instruction "$TSKEND" cannot be inserted as a user instruction

Then I tried text export and import

the whole file is
Code: [Select]
// Options: Export code block eventlogger2 from address 0 to 1;
// Code Block delimiter instructions; Formatted Rung Comments;
// use Element names (no NickNames); rung/address annotations;
// <SPACE> parameter delimiter;
// Write/overwrite file C:\Projects\why_does_this_not_import.txt

PLC BX-DM1E-18ED23-D

// Beginning of Code Block eventlogger2
$TSK eventlogger2

// Rung eventlogger2#1
// Offset 0
STR ST1
OUT C222

// End of Code Block eventlogger2
$TSKEND eventlogger2

I changed all instances of eventlogger2 to eventlogger2_copy

the new file is
Code: [Select]
// Options: Export code block eventlogger2_copy from address 0 to 1;
// Code Block delimiter instructions; Formatted Rung Comments;
// use Element names (no NickNames); rung/address annotations;
// <SPACE> parameter delimiter;
// Write/overwrite file C:\Projects\why_does_this_not_import.txt

PLC BX-DM1E-18ED23-D

// Beginning of Code Block eventlogger2_copy
$TSK eventlogger2_copy

// Rung eventlogger2_copy#1
// Offset 0
STR ST1
OUT C222

// End of Code Block eventlogger2_copy
$TSKEND eventlogger2_copy


I import it with
As Code BLocks on, Ignore Element Documentation on and Ignore MEM_CONFIG Sections

Tools> Insert instructions from file

Errors:
[Error]   why_does_this_not_import copy.txt(10)   $TSK P1 Task: Invalid element type
[Error]   why_does_this_not_import copy.txt(18)   $TSKEND P1 Task: Invalid element type

when trying to insert as rungs I get the following errors

[Error]   why_does_this_not_import copy.txt(10)   $TSK P1 Task: Invalid element type
[Error]   why_does_this_not_import copy.txt(18)   $TSKEND P1 Task: Invalid element type

I could use some help duplicating the tasks I have written as I have a template I made that I need to use in a number of places throughout the code. Not being able to duplicate it and import the text file doesn't seem to be something that would be intentional.

If anyone has any tips, ideas, or solutions it would be an immense help and I would greatly appreciate it.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
A couple of issues.

The Insert Instructions has 2 Import modes.  The default is to insert as rungs of logic into a specific location of an existing code block.  The other is when you have an entire code block that you want to insert (not inside an existing code block).

Your .txt file contains a TASK code block, not just rungs of logic.  So you must choose the other option to insert As Code Blocks, which you tried.

You tried that and it failed differently.  It appears your .txt file has been modified and you are missing the memory configuration portion of the export that defines the heap item "eventlogger" and "eventlogger2".

Not sure how this was generated, but the Memroy Configuration section is missing.  This defines the areas that may need to be created in your new project that are missing (like a task heap item or a block of reals or whatever).

Here is a copy of the export I created that has that Memory Configuration section for the task (I UNchecked System Configuration since that section cannot be imported into an existing project, but the Memory Configuration can):

Code: [Select]
// Options: Export code block eventlogger3 from address 0 to 1;
// Code Block delimiter instructions; Formatted Rung Comments;
// Element Documentation Database w/Flags; Memory Configuration/Devices with User Add-Ons only;
// use Element names (no NickNames); rung/address annotations;
// <SPACE> parameter delimiter;
// Write/overwrite file D:\codeMTX\Design\Sample Projects\MyExport3.txt

PLC BX-DM1E-18ED13

#BEGIN MEM_CONFIG
 eventlogger3 TASK  0 -1
#END

// Beginning of Code Block eventlogger3
$TSK eventlogger3

// Rung eventlogger3#1
// Offset 0
STR ST1
OUT C222

// End of Code Block eventlogger3
$TSKEND eventlogger3

Note the eventlogger3 definition in the MEM_CONFIG section.

I tried it using the default "as instructions" and got your first set of errors since this is an entire TASK code block and cannot be inserted into an existing code block:
Code: [Select]
[Error] No logic inserted at $Main#1
[Error] Instruction "$TSK" cannot be inserted as a user instruction
[Error] Instruction "$TSKEND" cannot be inserted as a user instruction

I then repeated the Insert Instructions, but as a Code Block and the eventlogger3 TASK code block imported (see attached image).

The Import mechanism is powerful, but has lots of possibilities for failure since the .txt file can contain ANYTHING.  Sadly, the Export mechanism is the only good way to understand the requirements of the Import function.


Bobby Tables

  • Newbie
  • *
  • Posts: 3
Thanks for the assist and explanation of the errors. It can be hard one can't find something in the documentation that tells the user what to change to fix the issue. Am I missing some import documentation somewhere?

A couple of issues.

The Insert Instructions has 2 Import modes.  The default is to insert as rungs of logic into a specific location of an existing code block.  The other is when you have an entire code block that you want to insert (not inside an existing code block).


I had no idea you could just delete even the code block part and import it as rungs. I couldn't find that anywhere in the documentation.

The code below imports without issue with
as rungs of logic: on
Ignore Element Documentation: on
Ignore MEM_CONFIG Sections: on
Code: [Select]
// Rung eventlogger2#1
// Offset 0
STR ST1
OUT C222

The issue is the exports allow me to export without the mem config section included. Which is what I did. There was no memory config section to modify.
And the error message did not specify that I was missing said heap item definitions.
The same errors happen when I use I turn ignore mem config on.

But when I turn mem config on I then get a whole bunch of warnings and some errors because the mem config contains all of the addresses including some that were made with the ethernet/ip setup that now give the error that the name is too long despite being made in the program and never getting any error messages on it before now and the program itself functioning fine on the plc.
[Error]   why_does_this_not_import4_2.txt(495)   User Data Type Name length is too long(17); maximum length is 16 characters
why_does_this_not_import4_2.txt(495)   User Data Type Name must be 1 to 16 characters; no spaces, can contain only letters, numbers, and/or underscores, cannot start with a number; must be unique

It would be nice if the "Invalid Element Type" error message had at least some kind of hint like which part threw it off. But I get how many permutations there can be when designing error handling.

As for the error above how might I handle these errors, some don't make sense as  I have the same _ in other assembly names. What's stranger still is the name appears twice in the mem config section when no modifications were made in that section. only a simple replacement of "eventlogger2" with "event_logger4_1".

The main question now is:
How might I handle these errors? That UDT is in a bunch of places in my code. Do I need to delete most of the mem config except for the heap items and import that?

Code: [Select]
VI_On_Off_inst112
// Field Name, Data Type, Memory Layout, Read/Write, Display Format, Data View Detail
VI_On_Off_1_16_B, UWORD, 0:0, Read-Write, Native, Short
VI_On_Off_17_32B, UWORD, 0:1, Read-Write, Native, Short

mem config section:
Code: [Select]
  VIOnOffInstTwo VI_On_Off_inst112 decimal 1
 VIOnOffInstTwo VI_On_Off_inst112 decimal 1
« Last Edit: April 23, 2026, 03:20:44 PM by Bobby Tables »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Sadly, no.  Those details are left to the import/export mechanism itself.  There are so many things that COULD be documented - it would probably fill up a book.

The EXPORT mechanism and its output is the only documentation.

The IMPORT error messages could be more specific on how to address those errors (like mentioning options to choose during export, or specific sections to look at in the import file).

When exporting, it does not know what the specific items you are needing later on when you import, hence it includes a "superset".  Element Documentation - you get all of it.  Memory Configuration - you get all of it (with the option of including the built-ins).

The error message on the IMPORT could have known that there was no Mem Config section in the import, and reported that as part of the second attempt where there was the "$TSK P1 Task: Invalid element type" error message.

So something like
$TSK P1 Task: Invalid element type; import does not contain a MEM_CONFIG section that needs to define that invalid element
???

I think that may have helped point you to the Export "Memory Config" option???

You went the other route and did not need it as a code-block, but only as a rung "snippet", and just eliminated the $TSK start/end delimiter instructions, then imported as rungs (ha!).

Posting here is probably the best thing you can do to get some good answers (or on AD's Community forum).

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
I should mention that Window's clipboard COPY/PASTE format for Designer
code blocks
rungs
individual instructions
includes the TEXT form of the code that can be pasted into a different project.  So rather than use the EXPORT mechanism, use Ctrl+C, then paste it in NOTEPAD, then edit out the pieces/parts you don't need by hand (basically what you did).  Then use the IMPORT mechanism with THAT text file.

(The clipboard content is optimized compared to the general Export dialog).