# Pieces of string

**URL:** <https://tech-community.robotics.abb.com/t/pieces-of-string/9292>\
**Category:** RAPID Programming\
**Tags:** syntax, string\
**Created:** [January 22, 2020, 7:53pm UTC](https://tech-community.robotics.abb.com/t/pieces-of-string/9292 "2020-01-22T19:53:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aweber](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Aweber](https://tech-community.robotics.abb.com/u/Aweber)\
**Post date:** [January 22, 2020, 7:53pm UTC](https://tech-community.robotics.abb.com/t/pieces-of-string/9292/1 "2020-01-22T19:53:48Z")

</div>

I have string variables used to identify and store data in specific .txt files. however i would like to use portions of that data to further organize my text files. but I’m not certain how to store a portion of a string as another string.

EX.

VAR string Searchname:=“1067 Ladder\_Pth1\_R1\_S23”;  
or :=“1067 Ladder\_Pth7\_R2\_S2”  
or :=“1080 Liftarms\_Pth3\_R1\_S4”  
or :=“1390 Liftarms\_Pth6\_R1\_S1”

I would like to use the first 4 digits of Searchname as an identifier, say SearchID  
How would i go about doing such a thing?

Something like:

VAR String SearchID := left4 of Searchname;

I’m just don’t know the proper syntax

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [January 22, 2020, 7:58pm UTC](https://tech-community.robotics.abb.com/t/pieces-of-string/9292/2 "2020-01-22T19:58:59Z")

</div>

Use function StrPart, it will store the characters into another string variable. You specify the start position and the length, which sounds just like what you are asking.

---

<div class="post-metadata">

**Author:** ![Aweber](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Aweber](https://tech-community.robotics.abb.com/u/Aweber)\
**Post date:** [January 24, 2020, 2:51pm UTC](https://tech-community.robotics.abb.com/t/pieces-of-string/9292/3 "2020-01-24T14:51:54Z")

</div>

Totally worked, exactly what I needed. Thank you!!
