Source language: Translate to:

String joining

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

String joining

Postby rishi » Sun Dec 31, 2006 10:30 pm

You would be able to help somebody to me:

I Want by means of strings's utilization, joining :

01|02|03|04|05 to horse|cat|dog|squirrel|cow

That means that you see yourself that way:

01 horse|02 cat|03 dog|04 squirrel|05 cow

From now on, thank you very much

Gustavo
rishi
 
Posts: 71
Joined: Wed Oct 05, 2005 1:23 pm

Postby HPW » Mon Jan 01, 2007 1:38 am

You may use StrParse to put both lists in their own arrays.
Then use a loop to concat them together to the wanted combination.
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby Sam Cox » Mon Jan 01, 2007 10:15 am

Building on HPW's good advice, here is a bit of code to illustrate the use of StrParse and then concatenating the parts into the desired results.
Code: Select all
SetVar "[S1]" "01|02|03|04|05"
SetVar "[S2]" "horse|cat|dog|squirrel|cow"
StrParse "[S1]" "|" "[Num]" "[NumCount]"
StrParse "[S2]" "|" "[Word]" "[WordCount]"

If "[WordCount]" "<>" "[NumCount]"
  AlertBox "DEBUG" "WordCount not equal to NumCount"
Else
  Loop "1" "[NumCount]" "[N]"
    SetVar "[A[N]]" "[Num[N]] [Word[N]]"
  EndLoop
Endif

Now, [A1] = "01 horse", [A2] = "02 cat", and so on.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby rishi » Tue Jan 02, 2007 3:04 am

Thank you for responding so quickly.

[A[N]]'s result works, but when displaying it in one textbox or to write on one of its files txt, only [A1] visualizes the first chain himself, that is:

01 horse

What I need is :

01 horse|02 cat|03 dog|04 squirrel|05 cow

Again many thanks.

Gustavo
rishi
 
Posts: 71
Joined: Wed Oct 05, 2005 1:23 pm

Postby HPW » Tue Jan 02, 2007 3:21 am

Extent Sam's code a bit:

Code: Select all
SetVar "[S1]" "01|02|03|04|05"
SetVar "[S2]" "horse|cat|dog|squirrel|cow"
StrParse "[S1]" "|" "[Num]" "[NumCount]"
StrParse "[S2]" "|" "[Word]" "[WordCount]"
SetVar "[StrAll]" ""

If "[WordCount]" "<>" "[NumCount]"
  AlertBox "DEBUG" "WordCount not equal to NumCount"
Else
  Loop "1" "[NumCount]" "[N]"
    SetVar "[A[N]]" "[Num[N]] [Word[N]]"
  EndLoop
  Loop "1" "[NumCount]" "[N]"
    IF "[N]" "=" "1"
      SetVar "[StrAll]" "[A[N]]"
    ELSE
      SetVar "[StrAll]" "[StrAll]|[A[N]]"
    ENDIF
  EndLoop
Endif
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby rishi » Tue Jan 02, 2007 6:31 am

Many thanks Sam and Hans:

Now if himself I complete the process successfully and it accomplishes what I was wanting .

Just you are for utilizing with the plugin hpwTreeView.

Greetings.

Gustavo
rishi
 
Posts: 71
Joined: Wed Oct 05, 2005 1:23 pm


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests