Re: How do i call a procedure
Posted: Tue Aug 08, 2017 6:03 pm
OK, I'll be back.
Robert
Robert
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://hmgforum.com/
Code: Select all
#include "hmg.ch"
Function Main
/**************/
CLOSE ALL
SET DATE TO GERMAN
SET CENTURY ON
SET DATE FORMAT TO "DD.MM.YYYY"
SET TOOLTIPSTYLE BALLOON
cJahr := "2017"
dDat := date()
dDATE_1 := date() + 10
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 1200 ;
HEIGHT 300 ;
TITLE 'Fahrerspesen by RS 2017' ;
MAIN
DEFINE MAIN MENU
DEFINE POPUP 'D&atei'
ITEM "E&nde" ACTION Win_1.Release
END POPUP
DEFINE POPUP 'D&aten'
ITEM 'Tagesdaten bereitstellen' ACTION woche()
ITEM 'Tagesdaten einlesen' ACTION filltag()
ITEM 'Enter date' ACTION datum()
END POPUP
DEFINE POPUP 'F&ahrerstamm'
ITEM 'Suchen' ACTION suchen()
END POPUP
END MENU
@ 80,10 DATEPICKER date_1 ;
TOOLTIP 'Datum ' ;
SHOWNONE ;
VALUE dDATE_1;
ON CHANGE fill_Label_date_1()
@ 100,10 LABEL Label_date_1 ;
VALUE "" ;
WIDTH 175 ;
HEIGHT 35 ;
FONT 'Arial' SIZE 09
END WINDOW
SetProperty('Win_1', 'date_1','Visible', .F.)
SetProperty('Win_1', 'Label_date_1','Visible', .F.)
ACTIVATE WINDOW Win_1
RETURN
FUNCTION datum()
/****************/
SetProperty('Win_1', 'date_1','Visible', .T.)
return
FUNCTION fill_Label_date_1()
/***************************/
SetProperty('Win_1', 'date_1','Visible', .F.)
SetProperty('Win_1', 'Label_date_1','Visible', .T.)
SetProperty('Win_1', 'Label_date_1','Value', dtoc(GetProperty('Win_1', 'date_1','Value')))
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
MSGINFO(dDATE_1)
SetProperty('Win_1', 'Label_date_1','Visible', .F.)
RETURN
FUNCTION woche()
/****************/
// YOU CAN USE DATE ALS HERE:
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
close all
nCnt:=0
use wochesdf exclusive
zap
append from woche.prn sdf
delete for empty(line) .or. substr(line,1,4)="Mita"
pack
use woche
zap
close all
use woche alias wo new exclusive
use wochesdf alias wosdf new
select wosdf
go top
do while !eof()
select wo
dbappend()
replace persnr with substr(wosdf->line,1,4),;
zeit with substr(wosdf->line,119,5),;
koge with substr(wosdf->line,125,5),;
kza with substr(wosdf->line,135,1),;
datum with ctod(substr(wosdf->line,110,6)+cJahr)
nCnt++
select wosdf
skip
enddo
MsgInfo(ltrim(str(ncnt))+ " records aufbereitet")
nCnt:=0
CLOSE ALL
Return
procedure filltag
/****************/
// YOU CAN USE DATE ALS HERE:
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
close all
cFehler:="N"
//dDatum:=ctod("")
dDat:=ctod("")
cPersnr:=space(4)
set cursor on
set confirm on
cName:=space(30)
cName1:=space(30)
use spesen alias spesen new
index on datum to datum
use woche alias woche new
go top
dDat:=woche->datum
select spesen
seek dDat
if found()
MsgInfo(dtoc(dDat)+" bereits verarbeitet")
return
endif
close all
use woche alias woche new
go top
astruct:={{"PERSNR","C",4,0},{"DATUM","D",8,0},{"KOMMT","C",5,0},{"GEHT","C",5,0},{"KZA","C",5,0}}
dbcreate("SPESENA",astruct,"dbfntx")
use spesena alias spa exclusive new
use bbpers alias pers new
index on persnr to persnr
select woche
do while !eof()
if !empty(woche->persnr)
cPersnr=woche->persnr
endif
select pers
seek cPersnr
// if found()
do dazu
// endif
select woche
skip
enddo
do fillspes
astruct:={{"DATUM","D",8,0},{"PERSNR","C",4,0},{"GRUND","C",30,0},{"KOMMT","C",5,0},{"GEHT","C",5,0}}
dbcreate("FEHLER",astruct,"dbfntx")
use FEHLER alias FEHLER exclusive new
use bbpers alias pers new
index on persnr to persnr
select spesen
dDat:=spesen->datum
//?dDat,spesen->datum
//wait
go top
do while !eof()
if empty(spesen->kommt) .or. empty(spesen->geht)
cName:="Zeitangabe fehlt"
select fehler
dbappend()
replace persnr with spesen->persnr,kommt with spesen->kommt,geht with spesen->geht,datum with spesen->datum,grund with cName
cFehler:="J"
endif
select spesen
skip
enddo
if cFehler="J"
select spesen
delete for datum=dDat
pack
MsgInfo(dtoc(dDat)+" nicht gespeichert,siehe Tabelle Fehler")
else
MsgInfo(dtoc(dDat)+" Daten eingelesen")
endif
return
procedure dazu
/****************/
// YOU CAN USE DATE ALS HERE:
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
select spa
dbappend()
replace persnr with cPersnr,datum with woche->datum,kza with woche->kza
if woche->koge="Kommt"
replace kommt with woche->zeit
else
replace geht with woche->zeit
endif
RETURN
PROCEDURE fillspes
/****************/
// YOU CAN USE DATE ALS HERE:
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
use woche exclusive
delete for empty(koge)
pack
close all
dDatum:=ctod("")
cPersnr:=space(4)
set cursor on
set confirm on
//Tagesdaten in Spesendatei einlesen
use spesen alias spesen exclusive new
use spesena alias spa new
select spa
do while !eof()
if !empty(spa->kommt)
select spesen
dbappend()
replace persnr with spa->persnr,datum with spa->datum,kommt with spa->kommt,kza with spa->kza
select spa
skip // IS THIS CORRECT? WHAT ABOUT EOF() BY NEXT SKIP?
select spesen
replace geht with spa->geht
endif
select spa
skip
enddo
return
procedure suchen
/****************/
// YOU CAN USE DATE ALS HERE:
dDATE_1 := GetProperty('Win_1', 'date_1','Value')
return
Congrats