| View previous topic :: View next topic |
| Author |
Message |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sun Mar 16, 2003 3:41 am Post subject: Why does this overwrite? |
|
|
I'm experimenting with the list command and I'm wondering about something. When I don't have anything selected in the list, type in a name and click the button then it gets added to the list.
But when I have a name selected and enter a name and click the button the name I entered overwrites the one in the list.
How can I avoid this?
| Code: | OPTION DECIMALSEP, "."
DIALOG CREATE,New Dialog,-1,0,314,214
REM *** Modified by Dialog Designer on 16.03.2003 - 04:30 ***
DIALOG ADD,LIST,LIST1,8,8,176,144,,DBLCLICK,SORTED
DIALOG ADD,EDIT,NAME,160,8,176,21
DIALOG ADD,BUTTON,BUTTON1,160,192,64,24,Add name
DIALOG ADD,STATUS,STATUS1
DIALOG SHOW
LIST PUT,LIST1,Robert Olsen
LIST PUT,LIST1,Bill Gates
LIST PUT,LIST1,Hames Hetfield
LIST PUT,LIST1,George Bush
:Evloop
wait "0.1",event
goto @event()
:Timer
DIALOG SET,STATUS1,Double click @dlgtext(LIST1) for more information.
goto Evloop
:BUTTON1BUTTON
LIST PUT,LIST1,@dlgtext(NAME)
goto Evloop
:LIST1DBLCLICK
INFO You double-clicked @dlgtext(LIST1)
goto Evloop
:Close
exit |
_________________
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Mar 16, 2003 4:06 am Post subject: |
|
|
To ADD items to a list, use LIST ADD.
LIST PUT will overwrite the item at the current index pointer.
LIST INSERT will insert the data in at the current index pointer.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Sun Mar 16, 2003 4:10 am; edited 2 times in total |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Mar 16, 2003 4:07 am Post subject: |
|
|
The list put command does just that, it puts the new text where the pointer
index to the current selection is. To append or add something use "List add,...".
To insert somthing use "list insert,..." and the new inserted text will be inserted before the current index position.  _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Mar 16, 2003 4:08 am Post subject: |
|
|
Darn it Mac  _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Mar 16, 2003 4:09 am Post subject: |
|
|
Also - ya can't use LIST PUT or LIST INSERT with SORTED lists...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sun Mar 16, 2003 4:50 am Post subject: |
|
|
OK, thanks for that guys.
And Mac, using LIST PUT on that sorted list works perfectly here  _________________
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Mar 16, 2003 4:55 am Post subject: |
|
|
Not my idea - this is from the VDS 3 help file:
PUT is used to write the specified text to the position in the list indicated by the index (pointer). PUT lets you treat a list as a random access file. Note that you cannot use PUT with sorted lists.
Copyright ©1995 - 2000 S.A.D.E. s.a.r.l. / All rights are reserved.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Mar 16, 2003 4:30 pm Post subject: |
|
|
Same thing from the VDS 4 help file:
| Quote: | PUT is used to write the specified text to the position in the list indicated by the index (pointer). PUT lets you treat a list as a random access file. Note that you cannot use PUT with sorted lists.
Copyright © 1995 - 2002 S.A.D.E. s.a.r.l. / All rights are reserved. |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sun Mar 16, 2003 4:44 pm Post subject: |
|
|
Yes I see that.
But why does this work then? | Code: | OPTION DECIMALSEP, "."
DIALOG CREATE,New Dialog,-1,0,314,214
REM *** Modified by Dialog Designer on 16.03.2003 - 04:30 ***
DIALOG ADD,LIST,LIST1,8,8,176,144,,DBLCLICK,SORTED
DIALOG ADD,EDIT,NAME,160,8,176,21
DIALOG ADD,BUTTON,BUTTON1,160,192,64,24,Add name
DIALOG ADD,STATUS,STATUS1
DIALOG SHOW
LIST PUT,LIST1,Robert Olsen
LIST PUT,LIST1,Bill Gates
LIST PUT,LIST1,Hames Hetfield
LIST PUT,LIST1,George Bush
:Evloop
wait "0.1",event
goto @event()
:Timer
DIALOG SET,STATUS1,Double click @dlgtext(LIST1) for more information.
goto Evloop
:BUTTON1BUTTON
LIST PUT,LIST1,@dlgtext(NAME)
goto Evloop
:LIST1DBLCLICK
INFO You double-clicked @dlgtext(LIST1)
goto Evloop
:Close
LIST COPY,LIST1
exit |
Try typing in more names and clicking the button. You'll see that they get added to the list sorted. _________________
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Mar 16, 2003 10:20 pm Post subject: |
|
|
SADE prolly put that in the help file for a reason. For example,
it may get flaky on larger lists, or may conflict with something
you haven't tried yet, or may act differently on another OS, etc.
It's usually a pretty good idea to heed a developer's warning
when they say you CANNOT or SHOULD NOT do something.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Mar 16, 2003 10:34 pm Post subject: |
|
|
I couldn't agree with Mac more. It's the same with any warnings that I
might put in one of my dlls. I put those warnings there for a reason. Mainly
to prevent any undesirable operations. SSTreeVw.dll is a good example.
Because using the CLICK and DBLCLICK styles together on the same
treeview control produces undesirable results, I suggested not to use those
two styles together. Mainly, because the DBLCLICK event actually generates
two events, and the first event will be interpreted as a CLICK event even
though it's a double click.
Another thing about "List put", is it's used to rewrite an existing list item,
where as "List add" is used to append a new item to a list and "List insert"
is used to insert a new item before the list index pointer.
"List put" is generally used when using a list in a random access kind of
manner. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Mon Mar 17, 2003 2:07 am Post subject: |
|
|
OK ok ok. I give
But I'm gonna try it on my laptop which is running Windows 95 a, and if it works there, then I'm gonna use it
Didn't mean to start something here. Just wanted to get some answers.
And what both you guys said makes sence.  _________________
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Mar 17, 2003 3:27 pm Post subject: |
|
|
No problem GeoTrail,
Trying/discussing different stuff is how we come up with a lot of
cool programs.
However...
Since a sorted list automatically re-arranges data (sorts alphabetically),
direct item manipulation could result in replacing/corrupting the wrong
item when the list sorts during the process (in a loop for example).
I would ask that ya do one thing - if ya post any code using LIST
PUT on sorted lists, please mention it in the code description so
users can be made aware of it.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Mar 17, 2003 3:39 pm Post subject: |
|
|
Hi GeoTrail,
In my experience with VDS List's. I have always found when using List Put that you should set the index pointer first to the item that you want to overwrite. It will keep the List command from overwriting something that it should not be overwriting. If all your doing is adding items to a list then just use List Add. The list add command takes no more work than the list put and list add will always place the item as the last item unless the list is a sorted list then you can use @index() to get the current index.
As you work more and more with VDS you will find that when the help file says a command or function is only used for this reason then usually it is very literal about that. VDS is a very literal language and the commands and function names are very literal about what they are for and do. That is part of the power of VDS and what makes it the fastest development environment on the Net... _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Mon Mar 17, 2003 5:29 pm Post subject: |
|
|
Yeah, you are both right guys *hitsmyself*
I've never thought about it that way, and I really can't argue with what you both said, so I guess I just have to follow your path
c:\windows\system32 was it?  _________________
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|