i am attaching code pls help regard
// Start of Program
Skip s = create
// Function to get the Text in Text Box
void insertElement(DBE txt)
{
int first,last
if (get(txt, first, last))
{
string ot = get txt
string selection = ot[first:last-1]
print selection
}
else
{
print "No selection\n"
}
}
void displayElement(DBE field)
{
}
void deleteElement(DBE field)
{
}
// Start Dialog Box Program ...
DB test = create("Prakash Window")
DBE txt = text(test,"Enter Name :","",30,false)
DBE cmd_insert = button(test,"Insert",insertElement)
DBE cmd_display= button(test,"Display in text Box",displayElement)
DBE cmd_delete= button(test,"Delete Element",deleteElement)
string str[32]
int count
put(s,1,"Person1")
put(s,2,"Person2")
put(s,3,"Person3")
put(s,4,"Person4")
put(s,5,"Person5")
for(count=0;count<=5;count++)
{
str[count] = null
find(s,count+1,str[count])
}
DBE coffeeList = list(test, "Choose one of:", 10, str)
show test
// End of Dialog Box
the short answer is simple: use the routines "insert" and "delete" :-)
The longer answer is attached below, a modified version of your code
with some
explanations.
There are a couple of important things:
First, I defiend the important elements, "coffeeList" and "txt" prior
to all routines, thus one can access them from within the routines.
Second, I skipped the Skip List. Why storing the information in a skip
list, if, after all, you want to have it in the dialog box list
element.
Third: I changed "txt" to be a field element, i.e. containing only one
line of text.
Here is the code:
// Start of Program
/*
test
*/
// Define the global variables here, i.e. the dialog box elements you
want
// to modify with your routines
DB test = create("Prakash Window")
DBE txt
DBE coffeeList
// Function to get the Text in Text Box
void insertElement(DBE x)
{
// Read the field element "txt"
// If it is nit null, find the currently selected element
// in the list and ass "txt" before.
string s = get txt
int i
if (!null s)
{
// "i" will be the currently selected item
i = get coffeeList
insert(coffeeList, i, s)
}
}
void displayElement(DBE x)
{
// Here you'll see that "get" is tricky:
// In the first call, it returns the index of the selected element
int i = get coffeeList
if (i >= 0)
{
// In the second call, it returns the value of the selected element
string name = get(coffeeList, i)
set(txt, name)
}
else
set(txt, "No selection")
}
void deleteElement(DBE field)
{
int i = get coffeeList
if (i >= 0) delete(coffeeList, i)
}
// Start Dialog Box Program ...
txt = field(test, "Enter name:", "", 30, false)
DBE cmd_insert = button(test,"Insert",insertElement)
DBE cmd_display= button(test,"Display in text Box",displayElement)
DBE cmd_delete= button(test,"Delete Element",deleteElement)
string str[] = {}
coffeeList = list(test, "Choose one of:", 10, str)
realize test
int i
for i in 0:4 do insert(coffeeList, i, "Person " (i+1) "")
show test
// End of Dialog Box
Cheers,
Peter
Regards
Prakash