forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Why does this overwrite?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sun Mar 16, 2003 3:41 am    Post subject: Why does this overwrite? Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Mar 16, 2003 4:06 am    Post subject: Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Sun Mar 16, 2003 4:07 am    Post subject: Reply with quote

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. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Sun Mar 16, 2003 4:08 am    Post subject: Reply with quote

Darn it Mac Evil or Very Mad Mr. Green
_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Mar 16, 2003 4:09 am    Post subject: Reply with quote

Also - ya can't use LIST PUT or LIST INSERT with SORTED lists... Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sun Mar 16, 2003 4:50 am    Post subject: Reply with quote

OK, thanks for that guys.

And Mac, using LIST PUT on that sorted list works perfectly here Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Mar 16, 2003 4:55 am    Post subject: Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Mar 16, 2003 4:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sun Mar 16, 2003 4:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Mar 16, 2003 10:20 pm    Post subject: Reply with quote

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. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Sun Mar 16, 2003 10:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Mon Mar 17, 2003 2:07 am    Post subject: Reply with quote

OK ok ok. I give Confused

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 Wink

Didn't mean to start something here. Just wanted to get some answers.
And what both you guys said makes sence. Very Happy

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Mar 17, 2003 3:27 pm    Post subject: Reply with quote

No problem GeoTrail, Smile

Trying/discussing different stuff is how we come up with a lot of
cool programs. Wink

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. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Mar 17, 2003 3:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Mon Mar 17, 2003 5:29 pm    Post subject: Reply with quote

Yeah, you are both right guys *hitsmyself* Embarassed
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 Wink

c:\windows\system32 was it? Laughing

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group