Dan,
I've looked at your test.imp. I give you credit for trying all of the available approaches.
(you've got a syntax issue there with an unnecessary '+' sign after the '=' operator)
(the rest is a mixed metaphor)
Let's focus and solve one thing at a time (of the two stated objectives: delete items from LB, and replacing text in a line).
As always there are several ways to accomplish something, so others may suggest better or more direct methods.
Deleting items from Listbox (at runtime).
First, I would set Listbox properties to have a variable, eg. LB01_selected, to 'store selected text'.Next, I'll just outline one approach you can try:
1. create a FOR LOOP to run through ALL of the lines of the ListBox (see later comments below)
2. you have a variable, 'selectedindex', for the User's choice
3. set a var revisedcontents = "";
4. make an IF statement if ( i != selectedindex)
5. then do something like this:
ListBox.SetListBoxSelection(i)
revisedcontents += LB01_selected ;
6. wait(0) //you may be able to eliminate this and see if it works without it
7. close the LOOP
8. ListBox.SetSelection(0, -1) ;
ListBox.ReplaceSelection( revisedcontents );
For the other part of the problem, here are some hints... you can explore how the following commands work together. Or, you may choose to use some other approach.
Code:
var charInfo = ListBox.LineIndex(1)
Debug.trace( "Line starts at \t" +charInfo +"\n")
var numOfChars = ListBox.LineLength(1)
Debug.trace( "Line length is \t" +numOfChars +"\n")
var numOfLines = CountLines(ListBox) //this same command can be used to count lines in a variable instead of an object
Debug.trace( "Object has \t" +numOfChars +"\t line(s)\n")
//the number of lines value can be useful for running through a FOR LOOP --- usually stop loop at i < numOfLines; //depending what you are doing
//for Your Replace Line 2
var UserNewInput = "Here is my new content" ; //you will adapt this to however you plan to get changes from User
ListBox.SetSelection(charInfo, charInfo +numOfChars -1) ;
ListBox.ReplaceSelection( UserNewInput );
//for Your Get 2
ListBox.SetListBoxSelection(1)
var ListBoxLine2 = LB01_selected ; //this assumes you have associated this variable, LB01_selected, to the ListBox in its Properties dialogue.
[Lar EDIT:] I have changed the index value in the 4th line above to 1 (it was 0, because I was testing those separately -- but we really want to operate on the same line)Dan, I chose to give this to you in pieces and in outline so you can think through what is going on... and once you get a feel for it I think you'll be able to reuse these methods and extend them later.