DO WHILE .NOT. EOF

This forum is for general support of Xbase++
Message
Author
Djiber
Posts: 27
Joined: Wed Feb 22, 2012 2:55 am

DO WHILE .NOT. EOF

#1 Post by Djiber »

I have function that's called with button click and it should populate DBF with DATA from another DBF.

I'm stuck cause I don't know why it doesn't do that for all DATA (It does it for 1'st line only)

Can some1 explain me what I'm doing wrong except everything :)

Code: Select all

FUNCTION Manj()

LOCAL ID:=Space(20), Dat, VP:=Space(5), VK:=Space(5)

USE Manj NEW INDEX Manj
USE Message NEW INDEX Datum, User
SET ORDER TO "Datum"

DO WHILE .NOT. EOF()

ID = FROM_USER
Dat = DATE

IF MSG = "In"

VP = TIME

ENDIF

IF MSG = "Out"

VK = TIME

ENDIF

SKIP

SELECT Manj
Mreza(); Append Blank
Mreza(); Replace	User_ID	With ID,;
			Datum	With Dat,;
			Vri_P	With VP,;
			Vri_K	With VK
CLOSE Manj

ENDDO

RETURN .T.

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: DO WHILE .NOT. EOF

#2 Post by GeneB »

You are not reselecting the dbf that you are trying to go to the end of.

Change the last lines to:

SELECT Manj
Mreza(); Append Blank
Mreza(); Replace User_ID With ID,;
Datum With Dat,;
Vri_P With VP,;
Vri_K With VK

// CLOSE Manj // delete this line and close it after the ENDDO loop
SELECT Message // add this line

ENDDO

// close the dbf's you have opened
// erase any indexes created only for this routine
RETURN .T.

Djiber
Posts: 27
Joined: Wed Feb 22, 2012 2:55 am

Re: DO WHILE .NOT. EOF

#3 Post by Djiber »

Thanks, that solved my problem

Or maybe not, I get only 10 lines now and again don't know why :(

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: DO WHILE .NOT. EOF

#4 Post by bwolfsohn »

USE Message NEW INDEX Datum, User
SET ORDER TO "Datum"

DO WHILE .NOT. EOF()


add a go top before the do while .not. eof()
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

Djiber
Posts: 27
Joined: Wed Feb 22, 2012 2:55 am

Re: DO WHILE .NOT. EOF

#5 Post by Djiber »

Still I get just 10 Lines

Code: Select all

USER_ID	DATUM	VRI_P	VRI_K
AMIHA	1.3.2012		
ADMIN	1.3.2012		
AMIHA	1.3.2012		
ADMIN	1.3.2012		
ADMIN	1.3.2012		
AMIHA	1.3.2012		
AMIHA	1.3.2012		
ADMIN	1.3.2012		
ADMIN	1.3.2012	15:54	
ADMIN	21.3.2012	15:54	10:43
Is it problem cause some messages aren't In or Out, but just some gibberish so it's getting data just until he get all variables.
(I've changed 10'th entry into In and nothing changed so I guess that's not problem - Last entry doesn't have Vri_K now and Vri_P is 10:43)

Or is it maybe problem cause in Message DBF there's just 1 column with Messages

Code: Select all

FROM_USER	DATE	TIME	MESSAGE
AMIHA	1.3.2012	14:37:26	sdfsadfasd
ADMIN	1.3.2012	14:41:03	"Hi"
AMIHA	1.3.2012	15:08:38	"Hi"
ADMIN	1.3.2012	15:08:51	"Sup"
ADMIN	1.3.2012	15:09:02	hedsgsfdg
AMIHA	1.3.2012	15:16:03	sdgdfgsd
AMIHA	1.3.2012	15:19:44	fdgadsasdf
ADMIN	1.3.2012	15:54:40	dfgsdfgdfg
ADMIN	1.3.2012	15:54:45	In
ADMIN	21.3.2012	10:43:54	Out
ADMIN	21.3.2012	16:04:11	In
ADMIN	21.3.2012	16:04:15	Out
ADMIN	21.3.2012	16:04:20	In
ADMIN	21.3.2012	16:04:23	In
ADMIN	21.3.2012	16:04:28	Out
ADMIN	21.3.2012	16:04:32	Out
I would like to accomplish that Manj.DBF take Time from same user that sent In and Out

I didn't even try that with user cause I had EOF problems :)

So basically I would like to do this:
Message.DBF:

Code: Select all

ADMIN 21.3.2012 16:04:32 In
John   21.3.2012 16:05:32 In
ADMIN 21.3.2012 16:24:32 Out
Steve  21.3.2012 16:32:32 In
Steve  21.3.2012 16:36:32 Out
John   21.3.2012 16:40:32 Out
Manj.DBF

Code: Select all

ADMIN 21.3.2012 16:04:32 16:24:32
John   21.3.2012 16:05:32 16:40:32
Steve  21.3.2012 16:32:32 16:36:32

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: DO WHILE .NOT. EOF

#6 Post by skiman »

Hi,

Always work with the alias names. This way your code will be more readable.

Code: Select all

FUNCTION Manj()

USE Manj NEW INDEX Manj
USE Message NEW INDEX Datum, User
SET ORDER TO "Datum"

DO WHILE !message->(EOF())

  IF message->MSG = "In" .or. message->MSG = "Out"
    manj->(dbappend())  
    manj->user_id := message->from_user
    manj->datum := message->date
    manj->.... := message-> ...
  endif
  message->(dbskip(1))

ENDDO

close manj
close message
RETURN .T.
This way you will have shorter code.

Hope this sample helps.
Best regards,

Chris.
www.aboservice.be

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: DO WHILE .NOT. EOF

#7 Post by GeneB »

In your code, what does Mreza() do ?

Djiber
Posts: 27
Joined: Wed Feb 22, 2012 2:55 am

Re: DO WHILE .NOT. EOF

#8 Post by Djiber »

Mreza is function that's checking if DBF is edited by another user/computer.

Thanks skiman, I'll try to use Aliases and see will that solve my problem.

Still only 10 lines are checked :(

Code: Select all

USER_ID	DATUM	VRI_P	VRI_K
ADMIN	1.3.2012	15:54	15:54
ADMIN	21.3.2012	10:43	10:43

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: DO WHILE .NOT. EOF

#9 Post by bwolfsohn »

remove mreza() and see if you still only get 10 records.
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

Djiber
Posts: 27
Joined: Wed Feb 22, 2012 2:55 am

Re: DO WHILE .NOT. EOF

#10 Post by Djiber »

I did, same result, but I've solved my problem by creating function for Indexing and then reindex everything with it, now it works like a charm ( At least until I get some error :) ).

Now I just need to figure out how to filter same user and use his messages to get In and Out for every user.

Post Reply