Page 1 of 1

List Field (boxes)

Posted: Thu Aug 30, 2007 5:05 pm
by jonnox
Hi, I'm new to RR and am used to Java 2. I am trying to figure out how to input data to a list box and then use it if it is highlighted. I have a simple add button that adds a name but it always replaces the current contents of the list field. Is there any documentation on the different objects? Do the objects have functions that I can access (oo oriented thinking I know but that's what I am used to). Any help would be great.

Posted: Thu Aug 30, 2007 5:14 pm
by ShieldsOnTour
You know, that was the first thing I tried to do with rev too :-)

Anyway, assume you have a field you have called "MyField"

To add data to it

put "Hello world" & return after field "MyField"

To get the currently selected item from the list, have a look at selectedText in the docs.

Hope this helps.

Posted: Thu Aug 30, 2007 5:47 pm
by Klaus
Hi jonnox,

actually you should do this, if you do not want an empty but selectable line in your listfield:

Code: Select all

...
if fld "listfield" = empty then
  put "New entry" into fld "listfield
else
  put CR & "Another new entry" after fld "listfield"
end if
...
To get the content of the currently hilited line:
-> the selectedtext of fld "listfield"

To get the number of the currently hilited line:
-> the hilitedline of fld "listfield"

Hope that helps.


Best from germany

Klaus


P.S.
Please spread the word:
The best thing to do is to check all the stacks at:
http://downloads.runrev.com/section/scr ... rences.php

I wrote the one about controls in general :-)

Posted: Fri Aug 31, 2007 2:14 am
by jonnox
Thanks guys, it worked great! I really appriciate it. The only thing left now is to get rid of the extra "selectable line" once I delete a line. It seems that the line stays even though it is blank

Posted: Fri Aug 31, 2007 8:34 am
by Klaus
Hi jonnox,

???

...
delete line 3 of fld "listfield"
...

will NOT leave an empty and thus selectable line.
What do you do to delete a line?
Could you post your code?


Best

Klaus

Posted: Fri Aug 31, 2007 4:52 pm
by jonnox
Sorry, I suppose that would have helped in the begning.

Code: Select all

on mouseUp
  if the selectedline is empty then
    -- do nothing
  else
    delete the selectedline
  end if
end mouseUp
I have a list box (lstGrantor) and then an Add button and a Remove button. That code snipit is from remove. Below is from Add (which works now thank's to you :) )

Code: Select all

  ask "Enter name of Grantor" titled "Grantor"
  if it is empty then
    -- do nothing
  else
    if field lstGrantor is empty then
      put it into field lstGrantor
    else
      put CR & it after field lstGrantor
    end if
  end if
Basically I want them to Add names and then I am going to put them into variables to be used later. I just want them to be able to delete them if they make a mistake etc. Thanks again for all your help!

Jon

Posted: Fri Aug 31, 2007 5:55 pm
by Klaus
Hi jonnox,

you're welcome!

Important hint:
It is always a good idea to put names in quotes!
This will prevent surprises if you can get used to it ;-)
AND it is a tad faster, since the engine will check first if there is variable with that name!

...
put it into field "lstGrantor"
...


Best from germany

Klaus