Paradox Community

Items in pnews.paradox-programming

Subject:Re: Help with my code please example below
Date:16 Oct 2021 03:12:39 -0400
From:"Tony" <tracy.fairbrother@btopenworld.com>
Newsgroups:pnews.paradox-programming

"Kevin Zawicki" <numberjack@wi.rr.com> wrote:
>
> Kevin thanks for your help really appreciated it worked fine. Tony 
>
>>can you show me how this code will look please?
>
>I did
>see my code in first post
>change
>sDate = dateval("01/01/2019")
>
>
>this will loop 5 times taking every two weeks.
>
>The code I posted is a valid script paste it into a new script and run.
>
>
>You asked for two weeks, which I took as 14 days, but two weeks can mean
>many things.
>
>
>
>
>
>"Tony" <tracy.fairbrother@btopenworld.com> wrote:
>>
>>"Kevin Zawicki" <numberjack@wi.rr.com> wrote:
>>>
>>>Thanks Kevin
>>If I want to start on the 01/01/2019 then get data every two weeks what
>does
>>the code look like? Sorry Im not very good at this can you show me how
this
>>code will look please? Tony
>>
>>>
>>>
>>>small rough example
>>>paste into script for better reading
>>>
>>>;// there are many variations on this, Paradox has a robust set of date
>>handlers
>>>for its age
>>>method run(var eventInfo Event)
>>> var
>>>  sDate  date
>>>  eDate  date
>>>  qDate  string
>>> endvar
>>>
>>> sDate = today()
>>>
>>>
>>> for cnt from 1 to 5  ;// this loops 5 times, but you can set this to
loop
>>>until no data or whatever needed   or while dStart < today()
>>>  ;// I avoid while loops or make them have a infinite lopo exit    but
>>while
>>>will work
>>>
>>>  eDate = sDate + 14  ;// set end date two weeks out
>>>
>>>  qDate = ">=" + sDate.string() + ",<=" + eDate.String()
>>>  ;//  greater than or equal - or change dates to plus minus one and do
>>not
>>>use equal
>>>
>>>
>>>
>>>  qDate.view()
>>>
>>>
>>>
>>>  ;// do queries
>>>
>>>  ;//do add to collect table
>>>
>>>  sDate = eDate + 1 ;// set start date to next day after last end date
>>>
>>> endfor
>>>
>>>endMethod
>>>
>>>
>>>
>>>
>>>
>>>
>>>"Tony" <tracy.fairbrother@btopenworld.com> wrote:
>>>>
>>>>
>>>>Can someone help me with the code below please. I want to put a start
>date
>>>>in and move the code date forward to capture the next set of data. Example
>>>> So start 01/07/2019 until 15/07/2019. Do the analysis add to the stats2
>>>>table then move on 16/07/2019 until 31/07/2019 do the same add results
>>to
>>>>stas2 table. I want this to carry on until the end of my data which is
>>12/10/2021.
>>>>Not sure what im doing wrong .  
>>>>
>>>>
>>>>
>>>>proc StartDate(d date) date
>>>>; proc returns start date for given date
>>>>; if date is before 16th, start date is begining of month
>>>>	if day(d) < 16 then
>>>>		return( date(month(d),1,year(d)) )
>>>>    else
>>>>		return( date(month(d),16,year(d)) )
>>>>    endIf
>>>>endProc
>>>>
>>>>proc EndDate(d date) date
>>>>; proc returns end date for given date
>>>>; if date is before 16th, end date is 15,
>>>>; if date if 16th or later, end date is end of month
>>>>	if day(d) < 16 then
>>>>		return( date(month(d),15,year(d)) )
>>>>    else
>>>>		return( date(month(d),daysInMonth(d),year(d)) )
>>>>    endIf
>>>>endProc
>>>>
>>>>
>>>>method run(var eventInfo Event)
>>>>var qb query
>>>>	 TC TCursor
>>>>	 dStart, dEnd Date
>>>>	 mStart, mEnd Date
>>>>	 sDate String
>>>>	 mDate String
>>>>		 tab table
>>>> 
>>>>
>>>>	 endVar
>>>>
>>>>
>>>>	dStart = date(7,01,2018)
>>>>	mStart = date(7,16,2018)
>>>>   ; and now start looping
>>>>   while dStart < today()
>>>>		dStart = StartDate(dStart)
>>>>		dEnd   = EndDate(dStart)
>>>>		mStart = StartDate(mStart)
>>>>		mEnd   = EndDate(mStart)
>>>>		; create a condition for date      ex: ">=1.1.2018 , <=15.1.2018"
>>>>      sDate = ">=01/07/2018,<="+string(dEnd)
>>>>      ; and now do something with this string
>>>>      ; put here your querys and do smething with them
>>>>
>>>>			mDate = ">="+string(mStart) + ", <="+string(mEnd)
>>>>
>>>>
>>>>
>>>>   qb= Query
>>>>ANSWER: :PRIV:ANSWER.DB
>>>>
>>>>OPTIONS: NO AUXILIARY TABLES
>>>>Stats1.DB | Race name | 
>>>>Delete    | not blank | 
>>>>
>>>>EndQuery
>>>>
>>>>		qb.executeQBE()
>>>>	  qb= Query
>>>>ANSWER: :WORK:Stats1.DB
>>>>
>>>>Stats1.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>>|
>>>>
>>>>          | Check     | Check    | Check   | Check  | Check  | Check

>
>>
>>>|
>>>>
>>>>
>>>>Stats1.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   |
>Name
>>>>  | 
>>>>          | Check     | Check   | Check  | Check  | Check  | Check  |
>Check
>>>> | 
>>>>
>>>>Stats1.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>>>>| 
>>>>          | Check  | Check  | Check  | Check  | Check  | Check  | Check
>>>
>>>>  | 
>>>>
>>>>Stats1.DB | ISP    | TFR    | Official time | Break time | Trainer |
Betfair
>>>>| 
>>>>          | Check  | Check  | Check         | Check      | Check   |
Check
>>>>  | 
>>>>
>>>>Stats1.DB | Race name_1 | Racetime_1 | Race No_1 | Date_1 | Grade_1 |
>
>>>>          | Check       | Check      | Check     | Check  | Check   |
>
>>>>
>>>>Stats1.DB | Distance_1 | Race type_1 | TfGoing_1 | Going_1 | Pos_1  |
>Btn_1
>>>> | 
>>>>          | Check      | Check       | Check     | Check   | Check  |
>Check
>>>> | 
>>>>
>>>>Stats1.DB | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1 | Bend.2_1 |
>
>>>>          | Check  | Check  | Check  | Check  | Check    | Check    |
>
>>>>
>>>>Stats1.DB | Bend.3_1 | Bend.4_1 | Comments_1 | ISP_1  | TFR_1  | 
>>>>          | Check    | Check    | Check      | Check  | Check  | 
>>>>
>>>>Stats1.DB | Official time_1 | Break time_1 | Trainer_1 | Betfair_1 |
RaceN
>>>> | 
>>>>          | Check           | Check        | Check     | Check     |
Check
>>>> | 
>>>>
>>>>EndQuery
>>>>
>>>>		qb.executeQBE()
>>>>
>>>> qb=Query
>>>>ANSWER: :WORK:Races.DB
>>>>
>>>>DogsDB.DB | Race name             | Racetime | Race No | Date       

>
>>
>>>
>>>>   | Grade  | 
>>>>			 | Check _join3, Crayford | Check    | Check   | Check _a,~mDate 

>|
>>>Check
>>>> | 
>>>>			 | Check _join3          | Check    | Check   | Check <_a        

>|
>>>Check
>>>> | 
>>>>
>>>>DogsDB.DB | Distance     | Race type | TfGoing | Going  | Pos    | Btn
>>
>>>
>>>> | 
>>>>          | Check _join2 | Check     | Check   | Check  | Check  | Check
>>>> | 
>>>>          | Check _join2 | Check     | Check   | Check  | Check  | Check
>>>> | 
>>>>
>>>>DogsDB.DB | Trap   | Name         | Age    | Sex    | Bend.1 | Bend.2
>|
>>>
>>>>          | Check  | Check _join1 | Check  | Check  | Check  | Check

>|
>>>
>>>>          | Check  | Check _join1 | Check  | Check  | Check  | Check

>|
>>>
>>>>
>>>>DogsDB.DB | Bend.3 | Bend.4 | Comments | ISP    | TFR    | Official time
>>>>| 
>>>>			 | Check  | Check  | Check    | Check  | Check  | Check         |

>>>>			 | Check  | Check  | Check    | Check  | Check  | Check         |

>>>>
>>>>DogsDB.DB | Break time                  | Trainer | Betfair | 
>>>>          | Check                       | Check   | Check   | 
>>>>          | Check _b,calc _b*0 as RaceN | Check   | Check   | 
>>>>
>>>>EndQuery
>>>>
>>>>	  qb.executeQBE()
>>>> play("RaceNo.ssl")
>>>>
>>>>  qb=Query
>>>>ANSWER: :WORK:ANSWER.DB
>>>>
>>>>Races.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>|
>>>>
>>>>         | Check     | Check    | Check   | Check  | Check  | Check 

>
>>|
>>>>
>>>>
>>>>Races.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   |
Name
>>>>  | 
>>>>         | Check     | Check   | Check  | Check  | Check  | Check  |
Check
>>>> | 
>>>>
>>>>Races.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>>>>| 
>>>>         | Check  | Check  | Check  | Check  | Check  | Check  | Check
>>
>>>
>>>> | 
>>>>
>>>>Races.DB | ISP    | TFR    | Official time | Break time | Trainer | Betfair
>>>>| 
>>>>			| Check  | Check  | Check         | Check      | Check   | Check 

>|
>>>
>>>>
>>>>Races.DB | Race name_1 | Racetime_1 | Race No_1 | Date_1 | Grade_1 |

>>>>         | Check       | Check      | Check     | Check  | Check   |

>>>>
>>>>Races.DB | Distance_1 | Race type_1 | TfGoing_1 | Going_1 | Pos_1  |
Btn_1
>>>> | 
>>>>         | Check      | Check       | Check     | Check   | Check  |
Check
>>>> | 
>>>>
>>>>Races.DB | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1 | Bend.2_1 |
Bend.3_1
>>>>| 
>>>>			| Check  | Check  | Check  | Check  | Check    | Check    | Check

>
>>
>>>|
>>>>
>>>>
>>>>Races.DB | Bend.4_1 | Comments_1 | ISP_1  | TFR_1  | Official time_1
|
>>
>>>>			| Check    | Check      | Check  | Check  | Check           | 
>>>>
>>>>Races.DB | Break time_1 | Trainer_1 | Betfair_1 | RaceN         | 
>>>>			| Check        | Check     | Check     | Check >0,<=8 | 
>>>>
>>>>EndQuery
>>>>
>>>>	qb.executeQBE()
>>>>
>>>>
>>>>	tab.attach("answer")
>>>>tab.add("Stats1",True,False) 
>>>>    
>>>> qb=Query
>>>>ANSWER: :WORK:NNett.DB
>>>>
>>>>Stats1.DB | Race name | Racetime | Race No | Date   | Grade     | Distance
>>>> | 
>>>>			 | Check     | Check    | Check   | Check  | Check A.. | Check 380
>|
>>>
>>>>
>>>>Stats1.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    |
ISP
>>>>   | 
>>>>			 | Check     | Check  | Check  | Check  | Check  | Check  | Check

>|
>>>
>>>>
>>>>Stats1.DB | Betfair | 
>>>>			 | Check   | 
>>>>
>>>>Stats1.DB | TFR_1                                                   

>
>>
>>>
>>>>                                                                    

>
>>
>>>
>>>>                            | 
>>>>			 | _a,calc _a*0 as RT2,calc _a*0 as RT2P,calc _a*0 as RT2C,calc _a*0
>>>as
>>>>RT4,calc _a*0 as RT4P,calc _a*0 as RT4C,calc _a*0 as RT6,calc _a*0 as
>RT6P,calc
>>>>_a*0 as RT6C | 
>>>>
>>>>Stats1.DB | 
>>>>			 | 
>>>>
>>>>Stats1.DB | RaceN                                                   

>
>>
>>>
>>>>                                                 | 
>>>>			 | calc _a*0 as BT6,calc _a*0 as RT6P,calc _a*0 as RT6Avg,calc _a*0
>>as
>>>>Tracp P,calc _a*0 as BT,calc _a*0 as Nocr | 
>>>>
>>>>EndQuery
>>>>
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>
>>>>	
>>>> qb=Query
>>>>ANSWER: :WORK:Adjtimes.DB
>>>>
>>>>Stats1.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>>|
>>>>
>>>>			 | Check     | Check    | Check   | Check  | Check  | Check    | 
>>>>
>>>>Stats1.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   |
>Name
>>>>  | 
>>>>			 | Check     | Check   | Check  | Check  | Check  | Check  | Check
>
>>|
>>>>
>>>>
>>>>Stats1.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>>>>| 
>>>>			 | Check  | Check  | Check  | Check  | Check  | Check  | Check   
|
>>
>>>>
>>>>Stats1.DB | ISP    | TFR    | Official time | Break time | Trainer |
Betfair
>>>>| 
>>>>			 | Check  | Check  | Check         | Check      | Check   | Check

>
>>|
>>>>
>>>>
>>>>Stats1.DB | Race name_1  | Racetime_1   | Race No_1    | Date_1     

>|
>>>
>>>>			 | Check _join1 | Check _join2 | Check _join7 | Check _join4 | 
>>>>
>>>>Stats1.DB | Grade_1      | Distance_1   | Race type_1 | TfGoing_1 | Going_1
>>>>| 
>>>>			 | Check _join6 | Check _join5 | Check       | Check     | Check 

>|
>>>
>>>>
>>>>Stats1.DB | Pos_1  | Btn_1  | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1
>>>>| 
>>>>			 | Check  | Check  | Check  | Check  | Check  | Check  | Check   
|
>>
>>>>
>>>>Stats1.DB | Bend.2_1 | Bend.3_1 | Bend.4_1 | Comments_1 | ISP_1  | TFR_1
>>>> | 
>>>>			 | Check    | Check    | Check    | Check      | Check  | Check  |
>
>>>>
>>>>Stats1.DB | Official time_1 | Break time_1 | Trainer_1 | Betfair_1 |
RaceN
>>>> | 
>>>>			 | Check           | Check        | Check     | Check     | Check

>|
>>>
>>>>
>>>>goingAllow.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>>>| 
>>>>				  | _join1    | _join2   | _join7  | _join4 | _join6 | _join5   |
>
>>>>
>>>>goingAllow.DB | GA     | 
>>>>				  | Check  | 
>>>>
>>>>EndQuery
>>>>
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>
>>>>
>>>>
>>>> qb= Query
>>>>ANSWER: :WORK:Adjtimes.DB
>>>>
>>>>
>>>>Adjtimes.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>>>| 
>>>>				| Check     | Check    | Check   | Check  | Check  | Check    | 
>>>>
>>>>Adjtimes.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap 

>|
>>>
>>>>				| Check     | Check   | Check  | Check  | Check  | Check  | 
>>>>
>>>>Adjtimes.DB | Name   | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4
>>>>| 
>>>>				| Check  | Check  | Check  | Check  | Check  | Check  | Check  |

>>>>
>>>>Adjtimes.DB | Comments | ISP    | TFR    | Official time | Break time
>|
>>>
>>>>				| Check    | Check  | Check  | Check         | Check      | 
>>>>
>>>>Adjtimes.DB | Trainer | Betfair | Race name_1 | Racetime_1 | Race No_1
>>|
>>>>
>>>>				| Check   | Check   | Check       | Check      | Check     | 
>>>>
>>>>Adjtimes.DB | Date_1 | Grade_1 | Distance_1 | Race type_1 | TfGoing_1
>|
>>>
>>>>				| Check  | Check   | Check      | Check       | Check     | 
>>>>
>>>>Adjtimes.DB | Going_1 | Pos_1  | Btn_1  | Trap_1 | Name_1 | Age_1  |
Sex_1
>>>> | 
>>>>				| Check   | Check  | Check  | Check  | Check  | Check  | Check  |
>
>>>>
>>>>Adjtimes.DB | Bend.1_1 | Bend.2_1 | Bend.3_1 | Bend.4_1 | Comments_1
|
>>ISP_1
>>>> | 
>>>>				| Check    | Check    | Check    | Check    | Check      | Check

>|
>>>
>>>>
>>>>Adjtimes.DB | TFR_1  | Official time_1 | Break time_1 | Trainer_1 | Betfair_1
>>>>| 
>>>>				| Check  | Check _a        | Check        | Check     | Check   

>|
>>>
>>>>
>>>>Adjtimes.DB | RaceN    | GA                         | 
>>>>				| Check >0 | Check _b,calc _a-_b as GAA | 
>>>>
>>>>EndQuery
>>>>
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>  qb=Query
>>>>ANSWER: :PRIV:ANSWER.DB
>>>>
>>>>OPTIONS: NO AUXILIARY TABLES
>>>>Adjtimes.DB | Distance_1 | Official time_1 | GA | GAA            | 
>>>>				|            | _c              | _b | changeto _c+_b | 
>>>>
>>>>EndQuery
>>>>
>>>>	qb.executeQBE()
>>>>
>>>>  qb=Query
>>>>ANSWER: :WORK:NNett.DB
>>>>
>>>>DogsDB.DB | Race name     | Racetime | Race No | Date              |
Grade
>>>> | Distance  | 
>>>>			 | Check Crayford | Check    | Check   | Check ~sDate     | Check

>|
>>>Check
>>>>380 | 
>>>>
>>>>DogsDB.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    |

>>>>			 | Check     | Check  | Check  | Check  | Check  | Check  | 
>>>>
>>>>DogsDB.DB | TFR                                                     

>
>>
>>>
>>>>                                                                    

>
>>
>>>
>>>>                            | 
>>>>			 | _a,calc _a*0 as RT2,calc _a*0 as RT2P,calc _a*0 as RT2C,calc _a*0
>>>as
>>>>RT4,calc _a*0 as RT4P,calc _a*0 as RT4C,calc _a*0 as RT6,calc _a*0 as
>RT6P,calc
>>>>_a*0 as RT6C | 
>>>>
>>>>DogsDB.DB | 
>>>>			 | 
>>>>
>>>>DogsDB.DB | Betfair                                                 

>
>>
>>>
>>>>                                                       | 
>>>>			 | Check calc _a*0 as BT6,calc _a*0 as RT6P,calc _a*0 as RT6Avg,calc
>>>_a*0
>>>>as Tracp P,calc _a*0 as BT,calc _a*0 as Nocr | 
>>>>
>>>>EndQuery
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>
>>>>
>>>> qb= Query
>>>>ANSWER: :PRIV:ANSWER.DB
>>>>
>>>>NNett.DB | Pos              | 
>>>>			| not 1,changeto 0 | 
>>>>
>>>>EndQuery
>>>>
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>	
>>>>
>>>> play("Lto2T.ssl")
>>>>
>>>> play("Lto4.ssl")
>>>>
>>>>  play("Lto6.ssl")
>>>>
>>>>	play("BT8.ssl")
>>>>	play("Fitness.ssl")
>>>>
>>>>  qb=Query
>>>>ANSWER: :PRIV:ANSWER.DB
>>>>
>>>>OPTIONS: NO AUXILIARY TABLES
>>>>NNett.DB | Race name | Racetime | Race No | Date   | Name   | Betfair
>
>>
>>>
>>>> | 
>>>>			| _join1    | _join2   | _join3  | _join4 | _join5 | changeto _a |
>
>>>>
>>>>BetfairSp.DB | Race name | Racetime | Race No | Date   | Name   | Betfair
>>>>| 
>>>>				 | _join1    | _join2   | _join3  | _join4 | _join5 | _a      | 
>>>>
>>>>EndQuery
>>>>
>>>>  qb.executeQBE()
>>>>
>>>>	 qb=Query
>>>>ANSWER: :WORK:ANSWER.DB
>>>>
>>>>NNett.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>>|
>>>>
>>>>         | Check     | Check    | Check   | Check  | Check  | Check 

>
>>|
>>>>
>>>>
>>>>NNett.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    | Betfair
>>>>| 
>>>>         | Check     | Check  | Check  | Check  | Check  | Check  | Check
>>>>  | 
>>>>
>>>>NNett.DB | RT2    | RT2P   | RT2C   | RT4    | RT4P   | RT4C   | RT6

>
>>
>>>|
>>>>
>>>>         | Check  | Check  | Check  | Check  | Check  | Check  | Check
>>
>>>|
>>>>
>>>>
>>>>NNett.DB | RT6P   | RT6C   | BT6    | RT6P_1 | RT6Avg | Tracp P | BT

>
>>
>>>
>>>>| 
>>>>         | Check  | Check  | Check  | Check  | Check  | Check   | Check
>>>
>>>>| 
>>>>
>>>>NNett.DB | Nocr   | 
>>>>         | Check  | 
>>>>
>>>>EndQuery
>>>>
>>>>	  qb.executeQBE()
>>>>  	tab.attach("answer")
>>>>tab.add("Stats2",True,False) 
>>>> 
>>>>
>>>>
>>>>			
>>>>
>>>>		; and at the end prepare data for next iteration
>>>>		dStart = dEnd+1
>>>>		mStart = mEnd+1
>>>>	  
>>>>	endWhile
>>>>
>>>>
>>>
>>
>


Copyright © 2004 thedbcommunity.com