Source language: Translate to:

ListBoxGetItemNumber

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

ListBoxGetItemNumber

Postby Leos » Tue Oct 23, 2007 5:23 pm

Hi,

It was very useful to have a command like this:

ListBoxGetItemNumber

Thankyou
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby beno » Tue Oct 23, 2007 7:11 pm

Hi Leos,

That option already exists in ListBox and ComboBox Objects.

You can enable/disable it using the "variable contains" radio boxes at the ListBox/ComboBox Properties window.

HTH,

beno

Edited later:

Oops! Forget my words... I see I misread your post.... :oops:
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Gaev » Tue Oct 23, 2007 7:33 pm

Leos:

You don't say what you want the desired command ListBoxGetItemNumber to do.

Cuurently NeoBook has 2 commands ...

a) ListBoxgetItem - Retrieve the text of an item in a List Box or Combo Box object

ListBoxGetItem "object name" "line number" "variable"
- line number: The line number of the item to retrieve.
- variable: The name of the variable to store the item’s text.

b) ListBoxFindItem - Search for an item in a List Box or Combo Box object.

ListBoxFindItem "object name" "item text" "variable"
- item text: The text of the item to find.
- variable: The name of the variable to store the number of the found item


... so do you want ListBoxGetItemNumber to do something different ?
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Leos » Wed Oct 24, 2007 11:36 am

Hi,

What i need is to get the number of selected option...

ex.
If I have this list

option1
option2
option3
.
.
.
option(n)

and I have selected option2, i want to know that I have selected itemNumber2 and her value (option2)

(in a really case, using something like this:

dbfFieldToVar "data" "field" "varValue" ""

if I have many equals values, i want to know the correct record (option2 => record2 in database 'data')

Thank you for your help
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Gaev » Wed Oct 24, 2007 12:16 pm

Leonel Bras:
and I have selected option2, i want to know that I have selected itemNumber2 and her value (option2)

For your ListBox/ComboBox you define ...

a) Variable: (to store selected item) ... e.g. [ListBox1], [ListBox2] or [selectedItem] etc.

b) Variable Contains: ... one of "Item number (1,2,3)" or "Item text"


Say you have [ListBox1] as the variable ... and the user picks the second item in your list from ...

option1
option2
option3
.
.
.
option(n)


If you choose Variable Contains: to be Item Number (1,2,3) then ...

- [ListBox1] will contain 2

- ListBoxGetItem "ListBox1" "[ListBox1]" "[ListBox1ItemText]" ... will contain option2 in [ListBox1ItemText]


If you choose Variable Contains: to be Item Text then ...

- [ListBox1] will contain option2

- ListBoxFindItem "ListBox1" "[ListBox1]" "[ListBoxItemNumber]" ... will contain 2 in [ListBox1ItemNumber]
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Leos » Wed Oct 24, 2007 12:56 pm

:idea:

Thank you Gaev!!!
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Leos » Wed Oct 24, 2007 6:04 pm

Hi, Gaev

don´t work with null values (al null values in the list assume itemNumber=0 ) :(

Best regards to you.

...so, my suggestion still in my wishlist...
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Gaev » Wed Oct 24, 2007 7:52 pm

Leonel:
don´t work with null values (al null values in the list assume itemNumber=0

Once again, it would help immensely if you were more descriptive about what you are trying to do ... specifically, what option are you using for the ListBox's Variable Contains: property ?

If you specify Item Number (1,2,3) then ...

a) [ListBox1] will contain the the number of the item selected ... does it not ?

b) ListBoxGetItem "ListBox1" "[ListBox1]" "[ListBox1ItemText]" ... will give you the content (text) of the selected item in [ListBox1ItemText] ... does it not ?

If not, what do you get instead ?

Remember that if you have a list with non-unique item text (e.g. two items with the text "abc") ... you HAVE to use Item Number (1,2,3) for the option Variable Contains: ... otherwise you will always get the number corresponding with the first matching item in the list.


...so, my suggestion still in my wishlist...

... and what exactly do you expect from the proposed ListBoxGetItemNumber command ... perhaps you can describe the parameters/options that would go with such a command ... and what values it would return.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Leos » Fri Oct 26, 2007 6:46 am

Hi Gaev

I'm sorry for my delay.

I will tray to explain my problem/wish:

I have [ListBox1] that stores user selections in [ListBox1Sel]
I need that [ListBox1] 'variable contains' returns the Item text (not Item Number)
...but, I need too to know the value of Item Number

The 'List items' are populated by the comand 'field to var' from my database.

your's solutions works fine just if i have not empty fields values
in this case, if i have 'List items' like this:

List item1value = [value1]
List item2value = [value2]
List item3value = [empty] (record field is empty)
List item4value = [value1]
List item5value = [empty] (record field is empty)
List item6value = [empty] (record field is empty)

the results from this real code

.ListBoxFindItem "ListBox107BC" "[CeitisID_MAGRO_sel]" "[ListBoxItemNumber]"
.dbfGotoSeqRecord "C:\NB\Moedas\Extras\Ceitis\DB\Ceitis.dbf" "[ListBoxItemNumber]"

do not work because:
....
returns:

List item1number = 1
List item2number = 2
List item3number= 0
List item4number = 4
List item5number = 0
List item6number = 0

and I have not the way to know the real value, that must be:

List item1number = 1
List item2number = 2
List item3number = 3
List item4number = 4
List item5number = 5
List item6number = 6

I´m sorry if im not clear (i have not any problem to read english language, my problem is to write it :roll: )
(I any case i wish that i can transmite to you my big thanks you for your's help :wink: )
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Gaev » Fri Oct 26, 2007 7:54 am

Leos:
I´m sorry if im not clear (i have not any problem to read english language, my problem is to write it
I have no problem understanding your English ... it is the lack of information that makes it difficult to make any useful suggestions ... I understand what you are trying to do ... but you seem to be fixated on geting a new NeoBook command (that I still don't know what you want it to do) ... and seem to be missing the point that a solution already exists ... so let me take another try and explain.


As I mentioned before ...

a) If you have a ListBox with duplicate items ... say the 2nd, 5th and 9th items all say "Portugal" ... then when you ask NeoBook to tell you what which item corresponds to "Portugal" ... currently NeoBook will return "2" ... the reason you get "0" returned for items with "null" text is probably because internally NeoBook stores "Item 0" as the null entry you see when a ListBox is not initialized ... but the problem is not limited to null entries ... it is just one case of "duplicate entries".

b) So, in order to meet your requirements ... you MUST define Variable Contains: as Item Number (1,2,3) ... so NeoBook can tell you EXACTLY which item (number) was selected by user.

c)
I have [ListBox1] that stores user selections in [ListBox1Sel]
I need that [ListBox1] 'variable contains' returns the Item text (not Item Number)
...but, I need too to know the value of Item Number
... I am confused ... when you say [ListBox1], do you mean "the object called ListBox1" or a "variable with that name" ? ... I am not sure what (text or number) you want stored in [ListBox1] and [ListBox1Sel].

d)
I need that [ListBox1] 'variable contains' returns the Item text (not Item Number)
...but, I need too to know the value of Item Number
... this can be worked around ... but since I do not know which variable is expected to contain the "Item Text" and which the "Item Number" of the selected item ... I am going to assume that ...

- [ListBox1] will contain the "Item Text"
- [ListBox1Sel] will contain the "Item Number"

... all you need to do is ...

i) change the Variable: (to store selected item) in the ListBox to [ListBox1Sel]

ii) Set the property Variable Contains: to be Item Number(1,2,3)

iii) in the Selection Changed section of this ListBox ...
Code: Select all
ListBoxGetItem "ListBox1" "[ListBox1Sel]" "[ListBox1]"



... and then [ListBox1] will always contain the text you want ... and [ListBox1Sel] the number of the selected item.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Leos » Fri Oct 26, 2007 1:15 pm

Hi, Gaev

This solution works, but my BIG problem is the other:

I have some aplicattions that works together. If i adopt this solution, the result is that in another aplication i get some errors (the variable of selected value is diferent...) and is not easy to (re)change correctly the code in many pubs (is not to change code, is recode...).

Really, i am not fixated on geting a new NeoBook command, but is really my oppinion that this line of code (this new command) will be useful for some of us. (and it goes on Neobook's line - simple and powerfull, in my oppinion :wink: )

Once more time, my congrats to you.
Best regards
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Gaev » Fri Oct 26, 2007 1:38 pm

Leonel:
I have some aplicattions that works together. If i adopt this solution, the result is that in another aplication i get some errors (the variable of selected value is diferent...) and is not easy to (re)change correctly the code in many pubs (is not to change code, is recode...).
That does not make sense at all ... if you are asking for a new command, then you are going to have to make changes in applications that don't work ... i.e. to deploy the new command ... so what is the difference between changing to this new command and changing the code to use the proper method that already exists ?

Note that with the suggestion I documented in my last post, you end up with the the desired values in the desired variables ... so any interaction with other applications should not be different ... hence I fail to see how this can cause errors in another application ... perhaps you can explain with a detailed example.

Really, i am not fixated on geting a new NeoBook command, but is really my oppinion that this line of code (this new command) will be useful for some of us. (and it goes on Neobook's line - simple and powerfull, in my oppinion )
Perhaps if you were to (as asked several times) provide details of how the syntax of this new proposed command would look like ... and what values NeoBook would be expected to return, perhaps we can see how it would be different from the current scenario ... in particular, details of how NeoBook should respond to non-unique (duplicate, triplicate, multi-cate) items in the list.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Leos » Fri Oct 26, 2007 2:44 pm

Gaev wrote:...Perhaps if you were to (as asked several times) provide details of how the syntax of this new proposed command would look like ... and what values NeoBook would be expected to return, perhaps we can see how it would be different from the current scenario ... in particular, details of how NeoBook should respond to non-unique (duplicate, triplicate, multi-cate) items in the list.


I´m really sorry if i'm not clear enought to transmite to you my problem... :cry:

What we have now:

ListBoxGetItem "ListBox1" "[line]" "[ListBox1Sel]"

just what i would like to see is this command:

ListBoxGetItemNumberSelected "ListBox1" "[line]"

where:

ListBox1 - the listbox object
[line] - the var where is stored the result

just so simple, without any more code to know [line]

....................

By the way, i have a similar request for this case:

we have:

ExtractFileName "[file]" "[fileName]" to extract the filename AND extension
ExtractFileExt "[file]" "[fileExtension]" to extract the file extension

but we don't have a command to have the filename without extension!

I know that is so easy to obtain that, but one thing is you can do it, the other thing is you have it, so simple (i use Function library), but in my modest opinion it make senses to have it so simple, something like my propuse:

ExtractFileName "[file]" "[fileName]" to extract the filename AND extension
ExtractFileExt "[file]" "[fileExtension]" to extract the file extension
new:
ExtractFileNameNoExt "[file]" "[fileNameNoExt]" to extract the filename WITHOUT extension

3º wish:
......................

the wish that neobooks command editor have the ability to complete the command (just other text editors)

example:

when you begin to write extr you press one key (for example space key) and you can choose from the existing commands (in this case, ExtractFileName, ExtractFileExt, ExtractFileNameNoExt and you can select one, and the editor complete the rest: ExtractFileName )

It is too mutch? (remember that Natal (Christmas) is at the gate, end the end users expect allways the best from the team :-)

My congrats to you and the team
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Postby Gaev » Fri Oct 26, 2007 6:16 pm

Leonel:
My congrats to you and the team
... LOL ... I am not part of the NeoBook team ... just an enthusiastic user of this great application development product.
just so simple, without any more code to know [line]
ExtractFileNameNoExt "[file]" "[fileNameNoExt]" to extract the filename WITHOUT extension
... this debate has been conducted on this forum before ... perhaps you missed it ... I have two reasons to oppose the addition of new commands just so developers can save the occasional bit of typing/command insertion ...

a) this is the exact reason most MS products have "bloat" ... a result of a common disease called "featuritis" ... the subroutines that support each NeoBook native command are automatically included in the base of the .exe file ... unlike plugins and functions ... so for each such command that is not really widely used in the develpment community, every .exe built by every NeoBook developer gets bloated ... using Functions (or just plain combination of NeoBook commands) only adds to the .exe files where used ... and not by the same amount.

b) you might be aware that Dave does not have the kind of programmer resources available to develop NeoBook enahncements that the big guys (like MicroSoft) has ... as a result, in my opinion, it is imperative that available resources be deployed "effectively and efficiently" ... if you look at the "big picture", this means that these resources should first be directed to providing functionality that can not be achieved otherwise ... and there are quite a few such requests ... some requested years ago ... that are still on Dave's "famous list" ... that have yet to rise to the top of the list ... so they can be realized in a future edition of NeoBook.

I am sure when you consider the above, you will see the greater good in focusing on the essentials vs. nice to have additional commands that at best save a couple of lines of code ... in a few applications ... for a few developers.

It is because I believe in this need for efficient deployment of limited available resources that I expend so much time on this forum ... so Dave can spend more time improving the parts of NeoBook that really make a difference.
the wish that neobooks command editor have the ability to complete the command (just other text editors)
Yes I have seen this feature in editors within other IDE's ... most of whom are based on the same "open source" code ... at least this suggestion won't add to the .exe size ... in some environments, where the "suggested word lists" popped up without pressing any kind of hot key, I found it annoying ... but some developers might find it helpful.

Note that the full list of commands is available in alphabetic order as well ... and I find that having the Help file open in another window does the job for me.
It is too mutch? (remember that Natal (Christmas) is at the gate, end the end users expect allways the best from the team
Christmas of which year ? ... seriously, with Dave working hard to complete the Reporting part of NeoBookDBPro ... and the afore mentioned list of outstanding requests from years ago, can you seriously expect your particular request to see the light of day this Christmas ... and if you are realistic, perhaps you can see the value of "biting the bullet" and implementing the suggested workarounds in your exisitng applications.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Wrangler » Sat Oct 27, 2007 8:39 am

ExtractFileName "[file]" "[fileName]" to extract the filename AND extension
StrParse "[fileName]" "." "[filearray]" "[numparsed]"

Filename in [filearray1] and ext in [filearray2]

One extra line of code. No bloat.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Next

Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron