 |
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: Thu Nov 24, 2005 4:59 am
string insert |
is there a function that does something like this?
it would be veeeeeeeeeeeeerrry convenient if there were.
queue = "first entry|second entry|fourth entry"
queue = %insert(@queue, "third entry", 3) |
|
|
 |
saplingg Novice
Joined: 06 Oct 2005 Posts: 31
|
Posted: Thu Nov 24, 2005 2:42 pm |
Err.. all I can think of is "%additem", but you probably knew that :)
|
|
|
 |
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: Thu Nov 24, 2005 11:33 pm aye |
yeah, additem unfortunately only adds to the end of the list, not to an arbitrary spot.
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Nov 25, 2005 7:08 am |
There's not one directly, but using %replaceitem() you can sneak in another element with a simple concatenation:
%replaceitem(@queue, 3,"third entry|fourth entry")
Not sure if that will generate a nested stringlist, though. If it does, you will have to do things in a slightly more roundabout way using a loop and %concat(). |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Fri Nov 25, 2005 4:20 pm |
Yes Matt that will create a nested stringlist.
gmueller create yourself an alias called addnitem and paste the following code into the settings dialog for it
Code: |
#if (%numparam != 3) {#echo Usage: addnitem variable number item;#abort 1}
#if (!%defined(%1)) {#echo Usage: addnitem expects the variable to already be defined;#abort 1}
#if (!%isnumber(%2)) {#echo Usage: addnitem only takes integers for the 2nd argument;#abort 1}
#if (%2 < 2) {#echo Usage: addnitem only takes integers 2 and greater for the 2nd argument;#abort 1}
#if (%2 > %numitems(@%1)) {#echo Usage: addnitem should not be given a 2nd argument greater than the number of items in the variable passed in the 1st argument;#abort 1}
#var tempaddn ""
#loop 1,(%2 - 1) {#additem tempaddn %item(@%1,%i)}
#additem tempaddn %3
#loop %2,%numitems(@%1) {#additem tempaddn %item(@%1,%i)}
#var %1 @tempaddn |
to put an item with spaces in make sure the 3rd argument is put in like "item with space" and make sure you don't do something like "first item|second item" otherwise once again you will end up with a nested stringlist. |
|
_________________ Taz :) |
|
|
 |
|
|