Wednesday, February 21, 2007

carla, you still owe me for this one!

A friend of mine called me recently at 1 a.m. and asked me for some coding help. I had insomnia so, i agreed to help.

Two hours of phone coding later this was the best i could do. Not bad, if you consider that all i had was a pen, some paper and her telling me if the code compiled successfully and if the result was what she expected.

By the way, if you know what kind of code this is and are looking for a job, send me your CV. I might know of a job opening for you.

local desconta, cod_subsrefeicao, N

desconta = .f.
cod_subsrefeicao = 107
N = 0

if txnlevel() = 0
select prre
scan
if prre.cr = 399 or (prre.cr <350 or >364)
desconta = .t.
N = N + prre.rqtt
end if
end scan
if N >0
goto top
scan
if prre.cr = cod_subsrefeicao
scatter name myPRRE
select prre
gather name myPRRE
replace prre.rqtt with rqtt
replace prre.ere with prre.ere * 1-(n/30)
replace prre.re with ((prre.re * N) /30)
replace prre.ervu with ((prre.ervu * N) /30)
REPLACE PRRE.RVU WITH ((PRRE.RVU * N) /30)
replace prre.Lordem with prre.Lordem * 100

scatter name myPRRE
select prre
append blank
gather name myPRRE
replace prre.rqtt with rqtt
replace prre.ere with ((prre.ere * N) /30) * -1
replace prre.re with ((prre.re * N) /30) * -1
replace prre.ervu with ((prre.ervu * N) /30) * -1
REPLACE PRRE.RVU WITH ((PRRE.RVU * N) /30) * -1
replcace prre.rem with "reembolso subsidio refeicÁ„o"
replace prre.Lordem with prre.Lordem * 100

m.mxsujirs = 0
m.mvirs = 0
declare a_diff (L),a_mesano(L),a_dtsuj(L)
a_diff = 0
a_mesano= 0
a_dtsuj= 0
do prantirs with pr.no, pr.data, m.eur_def
do prproc
do prprocf
exit
end if
end scan
else
goto top
scan
if prre.cr = cod_subsrefeicao
scatter name myPRRE
select prre
append blank
gather name myPRRE
replace prre.rqtt with rqtt
replace prre.ere with prre.ere * -1
replace prre.re with prre.re * -1
replace prre.ervu with prre.ervu * -1
REPLACE PRRE.RVU WITH PRRE.RVU * -1
replcace prre.rem with "reembolso subsidio refeicÁ„o"
replace prre.Lordem with prre.Lordem * 100

m.mxsujirs = 0
m.mvirs = 0
declare a_diff (L),a_mesano(L),a_dtsuj(L)
a_diff = 0
a_mesano= 0
a_dtsuj= 0
do prantirs with pr.no, pr.data, m.eur_def
do prproc
do prprocf
exit
end if
end scan
end if
end if
return prbairro

2 comments:

Unknown said...

FoxPro, and it sucks hard ;-)

Cheers,
PP

JP Antunes said...

Yes it is, and yes it does. :o)