News:

  • April 23, 2026, 11:33:45 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 28 times)

Bobby Tables

  • Newbie
  • *
  • Posts: 2
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: 3804
    • 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.