News:

  • May 05, 2026, 10:48:45 AM

Login with username, password and session length

Author Topic: Store String  (Read 10758 times)

Tark

  • Jr. Member
  • **
  • Posts: 16
Store String
« on: November 13, 2015, 12:30:57 PM »
What's the best way to store a string to memory?  I'm looking to store a constant into a memory location, like "Pump1".

HB_GUY

  • Full Member
  • ***
  • Posts: 43
Re: Store String
« Reply #1 on: November 13, 2015, 01:22:37 PM »
you can use one of the built in memory locations SSx (String Short) or SLx (String Long),
or create your own memory location for strings. The built in memory locations are retentive by default.

I needed to store extra long strings in my application so I created an SELx memory block (String Extra Long) to store my strings.


Tark

  • Jr. Member
  • **
  • Posts: 16
Re: Store String
« Reply #2 on: November 13, 2015, 01:43:50 PM »
I'm looking for the proper instruction to use to store a string like "Pump1" in my User Block, like in DL where you would LOAD "Pump1" and OUT V2000.  What's the best instruction to use to do something like that?

HB_GUY

  • Full Member
  • ***
  • Posts: 43
Re: Store String
« Reply #3 on: November 13, 2015, 01:53:35 PM »
You can use the STRINSERT command to insert simple strings,
or use STRPRINT to create complex strings

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Store String
« Reply #4 on: November 13, 2015, 02:21:39 PM »
I'm looking for the proper instruction to use to store a string like "Pump1" in my User Block, like in DL where you would LOAD "Pump1" and OUT V2000.  What's the best instruction to use to do something like that?

What is the user block data type?
"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

Tark

  • Jr. Member
  • **
  • Posts: 16
Re: Store String
« Reply #5 on: November 13, 2015, 02:32:29 PM »
I'll be writing the String to a Signed Word User Block.  I'm creating a user block for each device, so that user block will hold multiple types of data in it.  For instance the first word of the signed word user block will hold the status bits of the device, then next word in the data block might hold a setpoint for the device, etc.  I'm thinking about putting a string in the user block, such as a device ID, in order to view this in my SCADA.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Store String
« Reply #6 on: November 13, 2015, 02:34:47 PM »
The preferred way to access bytes in a string is STRGETB and STRPUTB. If the byte order is wrong, use SWAPB after.
"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

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Store String
« Reply #7 on: November 14, 2015, 12:33:59 PM »
My prefered method would be to create a user data block for each type of data.
Example:

First block: DevName String
Second block: DevRun Bit
Third block DevSpeed Unsigned word
Fourth block DevState Unsigned byte
Etc.

Now I would use a pointer to access each one.

Move 0 to V0 for device 1 (n-1 index).
Then read DevName [V0] for the device name.
SET DevRun [V0] to run the device.
Move 2047 to DevSpeed [V0] to set the speed at 50%.
Read DevState [V0] to get the device status.
Etc.

Move 3 into V0 and repeat for your fourth device etc.

As far as getting string data into a string, just use STRPRINT.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com