Split - keeping track of (and using) Index values

53 views
Skip to first unread message

Felix George

unread,
May 11, 2017, 9:57:42 AM5/11/17
to Eve talk
Is there a reliable way to use the Split function to split records while also keeping track of the ID's in a consistent way.  Every attempt at using this, the ID's get wonky and appear to do their own thing, but I'm sure it's just my lack of understanding how this really works.  Illustration below:
//Attempting to split long strings divided by the '$' character


rec = [task longstrings]

(token, index) = split[text: longstrings by: "$"]


commit
rec.newshortstring += [#shortstring1 text:token ID:index]   //first part of string after split
rec.newshortstring+= [#shortstring2 text:token ID:index + 2]    //second part of string after split


This clearly doesn't work.  The concept appears trivial to complete in c# but I can't wrap my head around it when working with the Split function and the way it handles indexes.  What I'm trying to do is turn some text, for example:  "first part $ second part" into two records with the tag #shortstring1 and #shortstring2 with the text equaling first part, second part respectively. and indexes 1 and 2.

What really happens is I get 50 different records with indexes going to 50 (I'm assuming because there are 50 total task records?).  Is there a more efficient and consistent to ensure that you only get an index 1 and 2 each time you split a string in half.

Felix George

unread,
May 11, 2017, 10:31:28 AM5/11/17
to Eve talk

On a related note, are the following functions available: concat | char-at | find | length | replace

co...@kodowa.com

unread,
May 11, 2017, 9:44:38 PM5/11/17
to Eve talk
Felix,

I've made a short example that accomplishes what you want:


The critical part is you don't need the line to commit the second `newshortstring`.You can handle it with a single record, that switches tag depending on if the text is at index 1 or index 2.

Does seeing this clarify how it works? I can provide a more detailed explanation if you need one.

> are the following functions available: concat | char-at | find | length | replace

Here are all the string functions in v02.3. We will have more in v0.3.

Corey

co...@kodowa.com

unread,
May 11, 2017, 9:45:16 PM5/11/17
to Eve talk


On Thursday, May 11, 2017 at 6:57:42 AM UTC-7, Felix George wrote:
Reply all
Reply to author
Forward
0 new messages