Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append blank and replace
Message
From
06/05/1998 11:15:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/05/1998 09:42:42
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00097155
Message ID:
00097351
Views:
25
>Cetin,
>
>Thank you for your reply
>underneath you find the code.
>
>It used to be a part of an older foxpro 2.6 program. As far as i can see it should work fine, what it does most of the time. Not always.
>I have had already changed the code into 'INSERT INTO' (that's why most of it has '*' in front of it), because I thought the problem could be there, but it keeps popping up. So even with with this code I sometimes have empty records...
>
>
>
>
>the '$$' marks are inserted to comment the program for you
>
> sele consol
> set order to consol
>
>$$: of course order consol is on xsysnr + prj + dtos(datum)
>
> ** maak record bij als nodig is
> if !seek(hp_ad.xsysnr+hp_ad.prj+dtos(hp_ad.datum))
>
>$$ : this is the problem-spot: append blank is always executed, but the replace command fails, sometimes. But: if you open the table with order 'consol' this record is shown in the sequence on the place it would have to have had when the fields 'dag', 'project' and 'xsysnr' were replaced normally. My conclusion is: the index was updated but the fields not, because they are empty...
>
> *append blank
> * if rlock()
> * replace dag with hp_ad.datum,;
> * project with hp_ad.prj,;
> * xsysnr with hp_ad.xsysnr
> * unlock
> * endif
> * sele pers
> * if seek(hp_ad.xsysnr)
> * sele consol
> * if rlock()
> * replace naam_op with alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam)
> * unlock
> * endif
> * endif
> *sele consol
>
> ** plaats in pers op juiste
> sele pers
> seek(hp_ad.xsysnr)
>
> sele consol
> insert into consol (dag,project,xsysnr,naam_op);
> values (hp_ad.datum,hp_ad.prj,hp_ad.xsysnr,alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam))
>
>
> endif
>
>
>Best regards
>Ivo
"My conclusion is: the index was updated but the fields not, because they are empty...". Regarding to your sentences I wonder if you're appending to "consol" when hp_ad is at eof() ? Revised the code some, try with this.
* Didn't change workarea to make sure some relation or underlying code doesn't move rec pointer
* I think current was hp_ad
* If fsizes do not match seek would always fail - so make sure of it
if eof()
	wait window "At EOF()"
	return
endif
if empty(hp_ad.xsysnr) ;
	or empty(hp_ad.prj) ;
	or empty(hp_ad.datum)
	wait window nowait "Warning! Empty field(s) in hp_ad"
endif	
cSeekExpr = padr(hp_ad.xsysnr,fsize("xsysnr","consol") + ;
	padr(hp_ad.prj,fsize("prj","consol")) + dtos(hp_ad.datum)   && In consol fname is prj or project ?
if !seek(cSeekExpr,"consol","consol")
	m.naam_op = iif(seek(hp_ad.xsysnr,"pers"),;
		alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam),"") && Assume order ready and fsizes match or less in hp_ad
	insert into consol (dag, project, xsysnr,naam_op) ;
		values (hp_ad.datum, hp_ad.prj, hp_ad.xsysnr, m.naam_op)
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform