News:

  • June 25, 2026, 05:07:24 PM

Login with username, password and session length

Author Topic: How many characters is enough?  (Read 56672 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: How many characters is enough?
« Reply #30 on: March 11, 2017, 07:00:22 PM »
1. When using groups strictly for organization, and while keeping the field name globally unique, it wouldn't be necessary or advantageous to require the full name (group.element.field) to be entered or displayed, while for true objects, the group name would be required for uniqueness.

Tres S7!  Over there you can create a Data Block, and put heap items inside, either singletons or n-D arrays (up to 4D I think?), and name them whatever you want. It gives you data organization namespace as well as storage-location-wise, and readable code.  For example, in one app I have a Burner DB, that has a bool element Permissive inside, referred in ladder as Burner.Permissive.  I do this a lot.  Very helpful.  (Though you can do user defined types as well, but I typically only do that for something repetitive, that you think of more as an object).

Quote
2. Since we are also adding user defined structure elements, there is clearly some overlap here. Do you construct your structure concept as true structures contiguous in memory and able to be added as memory blocks, but with the limitation of containing simple types only, or do you construct your structures as documentation objects, with the advantage of being able to contain any valid element...even strings and other structures...but only as random heterogeneous memory?

Don't necessarily see a conflict there.  Even with complex member types, the maximum size is known, so if you do an array in contiguous memory, you know how far apart to put them.  Maybe allow for default values and some sort of constructor mechanism because if you do anything that increases the struct size, they're all getting rewritten.

Quote
And yes Steve, you will be able to have symbolic constants in a namespace...so MaxFlow, Pump1.MaxFlow, Pump2.MaxFlow could be three different constants.

Yup, that's something I definitely want, but namespaces in general is even bigger.  Really, really want that.

Quote
And since a structure could be included in a namespace, we're kinda nesting structures too.

Yeah, but only two deep though!  ;D  Actually, two deep covers 80-90% of the use cases.

Final word -- whatever you do with namespaces, PLEASE ALLOW NAME WRAPPING IN LADDER DISPLAY!  Control Logix shot themselves in the foot here, bad.  They have a for the most part very good memory architecture, with user types, and so on, but if you really exploit it and use it to it's full potential, you end up with LONG variable names, like Tank[38].Heater.Safety.Overtemp, and THEY DON'T WRAP THE VARIABLE NAMES.  D'oh!  So if you are zoomed to where the text is readable, you might get two or three element across a screen display.
« Last Edit: March 11, 2017, 07:10:12 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: How many characters is enough?
« Reply #31 on: March 12, 2017, 11:33:10 AM »
Also, is it possible to export a program, pull out just the logic mnemonics, edit them and import back just the rungs I want into the existing program? So far I have only succeeded with the import as a new program and that means lots of things cause it to fail if they are not there yet (setting up the SERIO-4s for example.)

I didn't look hard enough! Select rungs in DmD and <Ctrl> + C. Open Wordpad and <Ctrl> + V. Make edits. Delete all the gobbledegook above the rungs I want and save file. Then in DmD, Select the location I want to insert in ladder. Tools > Insert Instructions From File...

I am guessing the gobbledegook needs to be there for something, but all attempts this morning to use it have been fruitless.

I can't get past the Insert Code Block errors. What does the (16) in the output window mean when it says:

[Error]   JoeBob.txt(16)   Invalid element type

Looking at the file I need to know where to look.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: How many characters is enough?
« Reply #32 on: March 12, 2017, 02:22:40 PM »
You are referencing a data type that hasn't been defined.

If you had the following logic:

STR X0
MATH N0 "D0+D1"

...and edited it to:

STR X0
MATH MyNewBlock0 "D0+D1"

And MyNewBlock was not already part of the configuration, you need to add it to the MEM_CONFIG definition.

It were an unsigned byte block you would add something like:

MyNewBlock UBYTE 1024 -1

Recommend you create a block like you want in the MemConfig and export it to see the proper syntax for what you need.

I'm sure Franj can elaborate more on the nuances of import/export/insert code/etc.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: How many characters is enough?
« Reply #33 on: March 12, 2017, 02:45:40 PM »
Considering I had copied a functioning block of code out to Notepad then tried to do the Insert Instructions (Code Block) I figured it would already have the needed memory blocks. I just looked and this was in it:

PLC DM-SIM

#BEGIN MEM_CONFIG
 MRXFailedVFD BIT decimal 64 -1
 MWXFailedVFD BIT decimal 64 -1
 DeadJimVFD BIT decimal 64 -1
#END

So what if anything does the (16) mean in:

[Error]   JoeBob.txt(16)   Invalid element type

I obviously need to start with something simpler to figure this out.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: How many characters is enough?
« Reply #34 on: March 12, 2017, 02:47:03 PM »
Considering I had copied a functioning block of code out to Notepad then tried to do the Insert Instructions (Code Block) I figured it would already have the needed memory blocks. I just looked and this was in it:

PLC DM-SIM

#BEGIN MEM_CONFIG
 MRXFailedVFD BIT decimal 64 -1
 MWXFailedVFD BIT decimal 64 -1
 DeadJimVFD BIT decimal 64 -1
#END

So what if anything does the (16) mean in:

[Error]   JoeBob.txt(16)   Invalid element type

I obviously need to start with something simpler to figure this out.


Please post JoeBob.txt, or the code at line 16 in that file.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: How many characters is enough?
« Reply #35 on: March 12, 2017, 02:47:57 PM »
So what if anything does the (16) mean in:

[Error]   JoeBob.txt(16)   Invalid element type

Sorry...it's the line number.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: How many characters is enough?
« Reply #36 on: March 12, 2017, 03:04:13 PM »
Please post JoeBob.txt, or the code at line 16 in that file.

I was trying not to do that  :-[ as it didn't like a second code block named Main so I changed it. It was late! And Spring Forward to boot.

Line 15: // Beginning of Code Block $Main
Line 16: $PRGRM $DangitBob

I had to use Notepad++ to even see the line numbers. I thought either Notepad or Wordpad had a status line but it seems not.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: How many characters is enough?
« Reply #37 on: March 12, 2017, 03:08:13 PM »
Program blocks are structures and must exist in memory as either a heap item or a block.

Add this line to the MEM_CONFIG section: DangitBob PROGRAM  0 -1

And drop the leading '$'. That's for system generated stuff.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: How many characters is enough?
« Reply #38 on: March 12, 2017, 03:31:34 PM »
Ahh, OK and thanks.

It's frustrating to know the answers are right there if I could just "see" them the right way.