NexusFi: Find Your Edge


Home Menu

 





How to split a sting with comma and put into an array


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 4 posts (6 thanks)
    2. looks_two ShahramTor with 3 posts (0 thanks)
    3. looks_3 huzisg with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 6,107 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 10 posts
    2. attach_file 0 attachments




 
Search this Thread

How to split a sting with comma and put into an array

  #1 (permalink)
huzisg
HANGZHOU,ZHEJIANG,CHINA
 
Posts: 6 since Aug 2016
Thanks Given: 0
Thanks Received: 0

HI, does anyone know how to split a string with comma to an array?

e.g.

str = "111,222,333,444,555"

arr[0] = "111";
arr[1] = "222";
...

thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


huzisg,

you should be able to accomplish that with using a while loop and the reserved words for string manipulation i.e.
LeftStr, RightStr, MidStr and InStr is what you can utilize here.
With these you can step through your string from comma to comma.

1. Have your loop check that there are still letters in your test string.
2. Take everything to the left of the first comma and store it in the array.
3. If there is no comma in the string, store the string in the array and set the test string to an empty string (so your loop can be exited).
4. Modify your test string so it now contains only the string to the right of the first comma.
5. You loop will repeat steps 2. to 4. until there is no new comma.

This should give you what you are looking for, but it will involve a bit of programming.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
huzisg
HANGZHOU,ZHEJIANG,CHINA
 
Posts: 6 since Aug 2016
Thanks Given: 0
Thanks Received: 0

So I known that there is no a function like "split" in vb, thanks for you reply.

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

No, unfortunately there isn't, but you should be able to easily accomplish what you have in mind following the four simple steps I described.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
ShahramTor
Onsala Sweden
 
Posts: 28 since Nov 2016
Thanks Given: 22
Thanks Received: 1


ABCTG View Post
huzisg,

you should be able to accomplish that with using a while loop and the reserved words for string manipulation i.e.
LeftStr, RightStr, MidStr and InStr is what you can utilize here.
With these you can step through your string from comma to comma.

1. Have your loop check that there are still letters in your test string.
2. Take everything to the left of the first comma and store it in the array.
3. If there is no comma in the string, store the string in the array and set the test string to an empty string (so your loop can be exited).
4. Modify your test string so it now contains only the string to the right of the first comma.
5. You loop will repeat steps 2. to 4. until there is no new comma.

This should give you what you are looking for, but it will involve a bit of programming.

Regards,

ABCTG

Hi,

How do you modify the test string? Is there any "SubStr" function or function which can return the length of a string?

Best regards
Shahram

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Shahram,

yes, there are. You can find them documented here: https://www.multicharts.com/trading-software/index.php/Category:Text_Manipulation including examples.

 
Code
StrLen( "My String" ) ;
The code above would for example return the length of this string.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
ShahramTor
Onsala Sweden
 
Posts: 28 since Nov 2016
Thanks Given: 22
Thanks Received: 1

Hello,

I want to find and delete character " (shit 2 - ASCII(34)) from a string.
Is there any function like ASCII(34) in EasyLanguage? (Because I can not write the character " in my code.)

EX: How do I write: Instr(MyStr,""") ?

Best Regards

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

ShahramTor,

take a look at the reserved word DoubleQuote, this might be helpful here.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
ShahramTor
Onsala Sweden
 
Posts: 28 since Nov 2016
Thanks Given: 22
Thanks Received: 1



ABCTG View Post
ShahramTor,

take a look at the reserved word DoubleQuote, this might be helpful here.

Regards,

ABCTG

Perfect. Thanks!

Reply With Quote




Last Updated on August 18, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts