| View previous topic :: View next topic |
| Author |
Message |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Mon Mar 03, 2003 6:29 am Post subject: @next() not dong the next thing |
|
|
hi all,
any reason why the following code does not return 1 and then 2, but instead returns 1 and then 1 again?
| Code: | list create, 1
list add, 1, 1
list add, 1, 2
list add, 1, 3
list add, 1, 4
list seek, 1, 0
info @item(1)
info @next(1) |
my understanding was that @next() displays the next item in a list, not the current one as stated in the manual - or did i read it wrong...
| Quote: | This function returns the contents of the next item in the string list <list>, that the pointer currently points to, and then advances the pointer by 1.
|
if however, i run the following then after the initial 1, it displays the result correctly: 1 1 2 3
| Code: | list create, 1
list add, 1, 1
list add, 1, 2
list add, 1, 3
list add, 1, 4
list seek, 1, 0
info @item(1)
info @next(1)
info @next(1)
info @next(1) |
Serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Mon Mar 03, 2003 7:13 am Post subject: |
|
|
Hi Serge!
Yeah, you got it a little wrong:
@NEXT() will return the current item and then advance to the next one.
@ITEM() will just return the current item and remain there.
So for your first example you'll need:
| Code: | info @next(1)
info @item(1) |
I guess the help file is not too clear on this point. Have a nice day, though
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Mar 03, 2003 9:58 am Post subject: |
|
|
My opinion - @next() is flaky, and has been in every VDS version
from the 16-bit freeware thru VDS 3x.
It may vary with OS or CPU makers - I don't really know what
the deal is, but I've had programs work fine on my comp and go
nuts on a user's computer. In one case it worked fine in a loop
until the data file (loaded into a list) got beyond a certain size.
Replacing @next() fixed the problem.
I use @item() instead (VDS3+ allows direct item access, earlier
versions require LIST SEEK first).
| Code: |
LIST CREATE, 1
LIST ADD, 1, Test0
LIST ADD, 1, Test1
LIST ADD, 1, Test2
%x = 0
REPEAT
INFO Item %x = @item(1, %x)
%x = @succ(%x)
UNTIL @greater(%x, @pred(@count(1)))
|
Most of you know I prefer fewer lines of code (and @next()
does use less), but I prefer stability even more...
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 |
|
 |
MarkTrubo Contributor


Joined: 27 May 2001 Posts: 148 Location: Long Island, NY
|
Posted: Mon Mar 03, 2003 2:01 pm Post subject: |
|
|
I have had similar problems with @NEXT() but simply assumed I was being stupid and just handled it as Mac descibed instead. So, we are either both stupid, or he is right -- it is a problem.  |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Mar 03, 2003 9:23 pm Post subject: |
|
|
LOL - could be "all of the above"...  _________________ 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: Tue Mar 04, 2003 1:24 am Post subject: |
|
|
 _________________
 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Mar 04, 2003 8:44 am Post subject: |
|
|
Strange thing.. I've never encountered diffifulties with @next() even though I've used it quite a lot
for cycling through databases with more than 100,000 recs.
But I've seen Mac's warning about @next() before, so I must admit that lately I've been using
@item() + an incrementing statement instead to cycle through files.
But I'm still curious: could you guys having had problems with @next() be a bit more specific?? Does
it skip recs, or get stuck somewhere, or what ?
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Mar 04, 2003 9:01 am Post subject: |
|
|
Typically, I use "%A = @next(1)" and have never encountered any
problems with this from VDS 2.x all the way on up to "Cough!!
Cough!".. Errrrr, all the way on up to VDS 4.x I mean. I've also had
this run on various pc's with the same result and never a problem.
In fact, Memory-Trax has been in distribution since late 1999 early 2000
using this style of @next(). Well over 500,000 users out there and not
once have I had an error report that was related to any list commands
or functions. It started in VDS 2.x and was eventually released using
VDS 3.x and a year later was upgraded using VDS 4.x.
I honestly believe that the issues a few of you have had with this are
isolated incidents related either to your style of programming, or a
specific issue with the pc's involved. Then again, maybe I'm just
lucky, and soon I'll start getting bug reports related to this.
Using @next() in the above manner has never failed me and I use it
in almost every program I have that has list related commands and
functions.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Tue Mar 04, 2003 10:35 am Post subject: |
|
|
thanks for all your comments
to me @next() should return the next item in a list and not the current one first before the next item (as mentioned by dr dread) but may be, as garrett says, it has to do with how i use @next() in my coding although mac does seem to have had some problems with it
perhaps "cough" will fix that...
Serge _________________
|
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Mar 04, 2003 10:46 am Post subject: |
|
|
| Garrett wrote: | I honestly believe that the issues a few of you have had with this are
isolated incidents related either to your style of programming, or a
specific issue with the pc's involved. |
| Mac wrote: | In one case it worked fine in a loop until the data file
(loaded into a list) got beyond a certain size. Replacing
@next() fixed the problem. |
Not sure how programming style could cause this...
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 |
|
 |
|
|
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
|
|