konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 7, 2020 15:02:24 GMT -5
Hello,
I have several strings like aa$(i), ab$(i), ac$(i) and sometimes one from each, sometimes 5 or more. Now I want collect them in one string. like: message$ = chr$( 34) +aa$(i) +"heeft" +ab$(i) +"sinds" +ac$(i) +chr$( 13) + the other strings. the next i's +chr$( 34) How can I do that, the next i in one line?
Thanks
Best regards,
Jack
|
|
|
Post by Rod on Mar 7, 2020 17:23:44 GMT -5
lasti=100 dim message$(100) for i = 1 to lasti message$(i) = aa$(i)+"heeft"+ab$(i)+"sinds"+ac$(i)'+ + + next
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 8, 2020 3:14:50 GMT -5
lasti=100 dim message$(100) for i = 1 to lasti message$(i) = aa$(i)+"heeft"+ab$(i)+"sinds"+ac$(i)'+ + + next Thanks Rod,
But the message$ must be a collection from all i
If i = 1 to 3 Then I must get
message$ = chr$( 34) +aa$(1) +"heeft" +ab$(1) +"sinds" +ac$(1) +chr$( 13) + chr$( 34) +aa$(2) +"heeft" +ab$(2) +"sinds" +ac$(2) +chr$( 13) +chr$( 34) +aa$(3) +"heeft" +ab$(3) +"sinds" +ac$(3) +chr$( 13) +
Otherwise I will post tonight my code and what it has to do.
Maybe I am on the wrong way....
|
|
|
Post by Rod on Mar 8, 2020 5:11:40 GMT -5
lasti=100 message$="" for i = 1 to lasti message$=message$+chr$(34) +aa$(i) +"heeft" +ab$(i) +"sinds" +ac$(i) +chr$(13) + chr$(34) next
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 8, 2020 15:45:17 GMT -5
This is my code:
OPEN "c:\test\out.dat" FOR OUTPUT AS #dat
print #dat, "DN390030003000010600030032702000300328020003003290300030031201000300313010" print #dat, "VN390030000001000000000" print #dat, "VN390030000002170000000" print #dat, "VN390030000003000000000" print #dat, "VN390030000004000000000" print #dat, "VN390030000005000000000" print #dat, "VN390030000006000000000" print #dat, "VN390030000007000000000" print #dat, "VN390030000008000000000" print #dat, "VN390030000009000000000" print #dat, "VN390030000010170000210" print #dat, "VN390030000011000000000" print #dat, "VN390030000012000000000" print #dat, "VN390030000013000000000" print #dat, "VN390030000014000000000" print #dat, "VN390030000015000000000" print #dat, "VN390030000016000000000" print #dat, "VN390030000017170000000" print #dat, "VN390030000018000000000" print #dat, "VN390030000019000000000" print #dat, "VN390030000020000000000" print #dat, "VN390030000021000000000" print #dat, "VN390030000022170000301" print #dat, "VN390030000023000000000" print #dat, "VN390030000024170000000" print #dat, "VN390030000025170000000" print #dat, "VN390030000026160000310" print #dat, "VN390030000027170000000" print #dat, "VN390030000028000000000" print #dat, "VN390030000029170500110" print #dat, "VN390030000030000000000" print #dat, "VN390030000031000000000" print #dat, "VN390030000032000000000" print #dat, "VN390030000033000000000" print #dat, "VN390030000034000000000" print #dat, "ZN" close #dat
OPEN "c:\test\out.dat" FOR INPUT AS #uit
dim aa$(1300) dim ab$(1300) dim ac$(1300) dim ad$(1300) dim ae$(1300) dim af$(1300) dim ag$(1300) dim ah$(1300) dim ai$(1300) dim aj(1300) dim ak$(1300) line input #uit,leeg1$ for i = 1 to 3000 aa$(i)= INPUT$(#uit, 2) if aa$(i) = "ZN" goto [einde] ab$(i)= INPUT$(#uit, 8) ac$(i)= INPUT$(#uit, 4) ad$(i)= INPUT$(#uit, 2) ae$(i)= INPUT$(#uit, 2) af$(i)= INPUT$(#uit, 2) ag$(i)= INPUT$(#uit, 1) ah$(i)= INPUT$(#uit, 4) if val(ag$(i)) = 1 then ai$(i) = "+" if val(ag$(i)) = 2 then ai$(i) = "++" if val(ag$(i)) = 3 then ai$(i) = "+++" if val(ag$(i)) > 0.5 then aj(i) = val(ac$(i)) print aj(i), "has", ai$(i), "from", ae$(i), "hour"
if aa$(i) = "ZN" goto [einde] end if next i close #uit
[einde] close #uit print "is gelukt"
The out.dat file comes out of my dairyfarm software. It says in code if a cow is in heat by a activitymeter. ac$ is the cow number, I have to use "val" to remove the 1 or 2 zerro's for the number ag$ show a number, 0 is normal activity, 1 is a litle bit, 2 more activity and 3 is a lot activity. I give it a +, ++ or a +++ (most activity) If the selection is done, cows who have 1 or more activty I want to use that for send a sms to my mobile. I have a sms gateway where I can send a email with the right data and they will send it to my mobile. I have a emailprogram which I can use from the command line:
For the sms I use this code:
text$ = "message" recognize$ = "recognise for authorisatie" mobilenumber$ = "yourmobbilenummer@bulksms.net" email$ = "youremailadres" server$ = "smtp.server" message$ = chr$( 34) +text$ +chr$( 34) print from$
cmd$ = "-s "; recognize$;_ 'from " -t "; mobilenumber$;_ 'to " -f "; email$;_ 'subject " -server "; server$;_ 'server " -body "; message$
run "C:\blat3212\full\blat.exe "; cmd$, HIDE
end
Now I want to have the message the selection of the cows who have activity and somthing like this in the sms: Cow 12 has +++ from 19 hour Cow 20 has + from 06 hour
This selction should be written in a file and and this program will run every hour but when nothing has changed in the activity the cow dont have to be send to sms each hour, so the written file has to be read and if the cow is already in the file and have the same + (for activity) do nothing. Maybe I can manage to write the last part but with to get al data in the message$ is a bit difficult for me. I hope I explain wel and you understand where I use it for otherwise let me know. Thanks Jack
|
|
|
Post by Rod on Mar 9, 2020 4:24:19 GMT -5
Ok, I don't understand enough to give a solution to the second part of the problem just yet. The code below just formats the "message$" from the data provided.
Now how will the data change over time? Just correct this example for cow 29 what will the file show each hour and what do you want the message to be? Does it time out after x hours?
time now is 18:00 file says cow 29 +++ from 17:00 time now is 19:00 file says cow 29 ++ from 17:00 time now is 20:00 file says cow 29 + from 17:00
This is how I would create the "message$" but without consideration of previous messages, that bit is still to do.
OPEN "out.dat" FOR OUTPUT AS #dat
print #dat, "DN390030003000010600030032702000300328020003003290300030031201000300313010" print #dat, "VN390030000001000000000" print #dat, "VN390030000002170000000" print #dat, "VN390030000003000000000" print #dat, "VN390030000004000000000" print #dat, "VN390030000005000000000" print #dat, "VN390030000006000000000" print #dat, "VN390030000007000000000" print #dat, "VN390030000008000000000" print #dat, "VN390030000009000000000" print #dat, "VN390030000010170000210" print #dat, "VN390030000011000000000" print #dat, "VN390030000012000000000" print #dat, "VN390030000013000000000" print #dat, "VN390030000014000000000" print #dat, "VN390030000015000000000" print #dat, "VN390030000016000000000" print #dat, "VN390030000017170000000" print #dat, "VN390030000018000000000" print #dat, "VN390030000019000000000" print #dat, "VN390030000020000000000" print #dat, "VN390030000021000000000" print #dat, "VN390030000022170000301" print #dat, "VN390030000023000000000" print #dat, "VN390030000024170000000" print #dat, "VN390030000025170000000" print #dat, "VN390030000026160000310" print #dat, "VN390030000027170000000" print #dat, "VN390030000028000000000" print #dat, "VN390030000029170500110" print #dat, "VN390030000030000000000" print #dat, "VN390030000031000000000" print #dat, "VN390030000032000000000" print #dat, "VN390030000033000000000" print #dat, "VN390030000034000000000" print #dat, "ZN" close #dat
OPEN "out.dat" FOR INPUT AS #uit
dim aa$(1300) dim ab$(1300) dim ac$(1300) dim ad$(1300) dim ae$(1300) dim af$(1300) dim ag$(1300) dim ah$(1300) dim ai$(1300) dim aj(1300) dim ak$(1300) line input #uit,leeg1$
message$=""
for i = 1 to 3000 aa$(i)= INPUT$(#uit, 2) if aa$(i) = "ZN" goto [einde] ab$(i)= INPUT$(#uit, 8) ac$(i)= INPUT$(#uit, 4) ad$(i)= INPUT$(#uit, 2) ae$(i)= INPUT$(#uit, 2) af$(i)= INPUT$(#uit, 2) ag$(i)= INPUT$(#uit, 1) ah$(i)= INPUT$(#uit, 4) if val(ag$(i)) = 1 then ai$(i) = "+" if val(ag$(i)) = 2 then ai$(i) = "++" if val(ag$(i)) = 3 then ai$(i) = "+++" if val(ag$(i)) > 0.5 then aj(i) = val(ac$(i))
message$=message$+str$(aj(i))+" has "+ai$(i)+" from "+ae$(i)+" hour."+chr$(13)+chr$(10)
if aa$(i) = "ZN" goto [einde] end if next i close #uit
[einde]
print message$
close #uit print "is gelukt"
|
|
|
Post by Rod on Mar 9, 2020 4:37:09 GMT -5
Thinking about it we probably need to keep a rolling history of each cows activity. The activity level each hour. How many hours do we need to track six, twelve? You don't want to keep a huge file but keeping every cows activity level for the last twelve hours is a nice small file. Each hour you just move the records back, drop of the oldes one and add the new one. Then use the file to pull out the message$ you want to see.
cow 29 0 0 0 0 0 1 2 3 2 1 0 0
since we know the time now, we can work out the start time and select the change levels you want to see. You would want to see increase to 2, increase to 3, decrease to 2?
If it is only the most recent change ou are interested in then perhaps we only need keep the last file and compare between the two, reporting increases or decreases last hour to this hour.
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 9, 2020 15:36:56 GMT -5
Yes, the message$ is good now, all selected cows are in, so I can send to the sms gateway. What you write about the level each hour is right. I get the out.dat file every hour or half an hour, just what you want. But the selection has been taken place in the farmdairy software. He send only a 1 or 2 or 3 if there is normal activity its a "0" What I have to do is make a selection off the cows who have a 1, 2 or 3 (ag$) and then you get the cows who have activity, that has to be send to the smsgateway, so I have a notfication without having to check in the computer. But the cows of that selection has to written down in a file. Next time Our program start, he has to import that file (tocht.dat) and check that with the selection he had the second time made. Are the same cows in with the same activity (1,2,or 3) he has to do nothing to send to the smsgateway. Otherwise I get every hour the same data. But it has to be written to the new tocht.dat file for the next time. If a cow have changed with activity from 2 to 3 or in figure ++ to +++ I want a notification of it by sms. If a cow dicrease with activity from +++ to + ( 3 to 1) the farmdairy software dont give a notification off it.
I have placed a file export in the code, but its not working well.
In the first lines, the file has be excist otherwise you get error.
I was thinking something like this:
i =0
while aj$ <> a$( i) and i <3000 i =i +1 if i = 3000 then print a$(i) wend But cant get it working..
dim a$(3000), b$(3000), c$(3000) i =0 open "tocht.dat" for input as #readFile while not( eof( #readFile)) inputcsv #readFile, a$(i), b$(i), c$(i) print a$(i), b$(i), c$(i) i =i +1 wend close #readFile
OPEN "out.dat" FOR OUTPUT AS #dat
print #dat, "DN390030003000010600030032702000300328020003003290300030031201000300313010" print #dat, "VN390030000001000000000" print #dat, "VN390030000002170000000" print #dat, "VN390030000003000000000" print #dat, "VN390030000004000000000" print #dat, "VN390030000005000000000" print #dat, "VN390030000006000000000" print #dat, "VN390030000007000000000" print #dat, "VN390030000008000000000" print #dat, "VN390030000009000000000" print #dat, "VN390030000010170000210" print #dat, "VN390030000011000000000" print #dat, "VN390030000012000000000" print #dat, "VN390030000013000000000" print #dat, "VN390030000014000000000" print #dat, "VN390030000015000000000" print #dat, "VN390030000016000000000" print #dat, "VN390030000017170000000" print #dat, "VN390030000018000000000" print #dat, "VN390030000019000000000" print #dat, "VN390030000020000000000" print #dat, "VN390030000021000000000" print #dat, "VN390030000022170000301" print #dat, "VN390030000023000000000" print #dat, "VN390030000024170000000" print #dat, "VN390030000025170000000" print #dat, "VN390030000026160000310" print #dat, "VN390030000027170000000" print #dat, "VN390030000028000000000" print #dat, "VN390030000029170500110" print #dat, "VN390030000030000000000" print #dat, "VN390030000031000000000" print #dat, "VN390030000032000000000" print #dat, "VN390030000033000000000" print #dat, "VN390030000034000000000" print #dat, "ZN" close #dat
OPEN "out.dat" FOR INPUT AS #uit OPEN "tocht.dat" FOR OUTPUT AS #tocht
dim aa$(1300) dim ab$(1300) dim ac$(1300) dim ad$(1300) dim ae$(1300) dim af$(1300) dim ag$(1300) dim ah$(1300) dim ai$(1300) dim aj(1300) dim ak$(1300) line input #uit,leeg1$
message$=""
for i = 1 to 3000 aa$(i)= INPUT$(#uit, 2) if aa$(i) = "ZN" goto [einde] ab$(i)= INPUT$(#uit, 8) ac$(i)= INPUT$(#uit, 4) ad$(i)= INPUT$(#uit, 2) ae$(i)= INPUT$(#uit, 2) af$(i)= INPUT$(#uit, 2) ag$(i)= INPUT$(#uit, 1) ah$(i)= INPUT$(#uit, 4) if val(ag$(i)) = 1 then ai$(i) = "+" if val(ag$(i)) = 2 then ai$(i) = "++" if val(ag$(i)) = 3 then ai$(i) = "+++" if val(ag$(i)) > 0.5 then aj(i) = val(ac$(i)) print #tocht, aj(i); ",";ai$(i);",";ae$(i) message$=message$+str$(aj(i))+" has "+ai$(i)+" from "+ae$(i)+" hour."+chr$(13)+chr$(10)
if aa$(i) = "ZN" goto [einde] end if next i
[einde]
print message$
close #uit close #tocht print "is gelukt"
|
|
|
Post by metro on Mar 9, 2020 19:37:09 GMT -5
You are increasing the value of i before you check for a condition ...are you sure about the condition?
i =0
while aj$ <> a$( i) and i <3000 if i = 3000 then print a$(i) i =i +1 wend But cant get it working..
|
|
|
Post by Rod on Mar 10, 2020 8:37:37 GMT -5
This is a little convoluted but it works, well it works the way I currently understand how you want it to work. I think you only need to look at the last report and compare to this report.
i =0 open "tocht.dat" for output as #writefile #writefile "cow,10,2,1,"; 'cow number ,last reading,hour #writefile "cow,22,3,1,"; #writefile "cow,26,2,2,"; #writefile "cow,29,1,5,"; close #writefile
open "tocht.dat" for input as #readFile lastreading$=input$(#readFile,lof(#readFile)) 'print lastreading$ close #readFile
OPEN "out.dat" FOR OUTPUT AS #dat
print #dat, "DN390030003000010600030032702000300328020003003290300030031201000300313010" print #dat, "VN390030000001000000000" print #dat, "VN390030000002170000000" print #dat, "VN390030000003000000000" print #dat, "VN390030000004000000100"'new so report at 1? print #dat, "VN390030000005000000000" print #dat, "VN390030000006000000000" print #dat, "VN390030000007000000000" print #dat, "VN390030000008000000000" print #dat, "VN390030000009000000000" print #dat, "VN390030000010170000310"'now 3 was 2 report print #dat, "VN390030000011000000000" print #dat, "VN390030000012000000000" print #dat, "VN390030000013000000000" print #dat, "VN390030000014000000000" print #dat, "VN390030000015000000000" print #dat, "VN390030000016000000000" print #dat, "VN390030000017170000000" print #dat, "VN390030000018000000000" print #dat, "VN390030000019000000000" print #dat, "VN390030000020000000000" print #dat, "VN390030000021000000000" print #dat, "VN390030000022170000301"'same reported, not to be included print #dat, "VN390030000023000000000" print #dat, "VN390030000024170000000" print #dat, "VN390030000025170000000" 'print #dat, "VN390030000026160000310"'less so not reported print #dat, "VN390030000027170000000" print #dat, "VN390030000028000000000" print #dat, "VN390030000029170600210"'now 2 was 1 so report print #dat, "VN390030000030000000000" print #dat, "VN390030000031000000000" print #dat, "VN390030000032000000000" print #dat, "VN390030000033000000000" print #dat, "VN390030000034000000000" print #dat, "ZN" close #dat
OPEN "out.dat" FOR INPUT AS #uit OPEN "tocht.dat" FOR OUTPUT AS #tocht
dim aa$(1300) dim ab$(1300) dim ac$(1300) dim ad$(1300) dim ae$(1300) dim af$(1300) dim ag$(1300) dim ah$(1300) dim ai$(1300) dim aj(1300) dim ak$(1300) line input #uit,leeg1$
message$=""
for i = 1 to 3000 aa$(i)= INPUT$(#uit, 2) if aa$(i) = "ZN" goto [einde] ab$(i)= INPUT$(#uit, 8) ac$(i)= INPUT$(#uit, 4)'cow ad$(i)= INPUT$(#uit, 2) ae$(i)= INPUT$(#uit, 2)'hour af$(i)= INPUT$(#uit, 2) ag$(i)= INPUT$(#uit, 1)'reading ah$(i)= INPUT$(#uit, 4) if val(ag$(i)) = 1 then ai$(i) = "+" if val(ag$(i)) = 2 then ai$(i) = "++" if val(ag$(i)) = 3 then ai$(i) = "+++" if val(ag$(i)) > 0.5 then aj(i) = val(ac$(i)) 'write to last record file all records or only those 1 or more? #tocht "cow,"+right$(ac$(i),2)+","+ag$(i)+","+ae$(i)+","; 'print "cow,"+right$(ac$(i),2)+","+ag$(i)+","+ae$(i)+","
report=0 'is the cow reported in the last file pos=instr(lastreading$,"cow,"+str$(aj(i)),1) if pos>0 then 'is the reading greater than last time? if val(ag$(i))>val(mid$(lastreading$,pos+7,2))then report=1 end if end if 'is the cow a conditional previous report or a new fresh report if (pos=0 and val(ag$(i))>0) or report then message$=message$+str$(aj(i))+" has "+ai$(i)+" from "+ae$(i)+" hour."+chr$(13)+chr$(10) end if
if aa$(i) = "ZN" goto [einde] end if next i
[einde]
print message$
close #uit close #tocht print "is gelukt"
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 11, 2020 6:43:37 GMT -5
Thanks Rod and Metro, for the help. I used your last code Rod and put the sms code below it. In the begin I make a file (in.dat) with a code en place that in the ISO directory off the Farmmanagment, with that code the software knows that I want de activity data and they send it as the out.dat file, what we import. I run the program each half an hour with the windows taskscheduler. If there is nothing I get nothing, if there is activity I get a sms. Works like a charme But I will test for the comming days.. A few questions. I have also cownumbers with 4 digits, like 1134 how to do that and if possible that cow 1 stays 1 and not 0001? The tocht.dat file, is it possible to write it as a csv file type? with a , for seperate, but each cow a new line? Then I can use that file also in another aplication. Thanks. Jack
|
|
|
Post by metro on Mar 11, 2020 7:35:10 GMT -5
A few questions. I have also cownumbers with 4 digits, like 1134 how to do that and if possible that cow 1 stays 1 and not 0001? Thanks. Jack Holy cow how many milkers do you have?, smarter people that I can answer if there are any benefits with starting from starting with 0001
Me personally, I think a database should be your future goal.
I'm guessing for 10 months of the year a cow is giving milk and as you dry her off for mating again you need to start measuring activity again.
So why not keep data on each cow for the productive life of the cow. (could be 15 years plus) you may see patterns in the heat cycle that give you a heads up to how long after calving any particular cows cycles.
And which genetic line falls pregnant again the quickest.
Be a bit of a pain if the whole herd synchronise , poor Bulls . ( or you with the straws) Maybe there are advantages!
I guess a CSV file for each cow would still work but SQlite gives you big advantages for extracting queries.
35 years ago I had three jersey cows for home consumption (milk and meat)
Maybe dedicate some time to hand writing a complete database design. (maybe examples already exists)
stay focused...all the best
|
|
|
Post by Rod on Mar 11, 2020 9:23:14 GMT -5
Yes I would dearly like to re write the software with meaningful names and a dedicated database. However the thing works! horray! This would help get more consistent results, keeping the data as it is found.
'from the farm software file It would be best to keep the data unchanged ac$(i)="1234" 'cow 0001-9999 length always 4 ae$(i)="05" 'hour 00-99 length always 2 ag$(i)="3" 'reading 0-3 length always 1?
'don't change these strings keep them as strings in your process 'if you need to compare values use val(ac$(i)) but the cow number is really just a "name"
'the word "cow" helps find the cows name 'so searching for "cow,0010" reliably finds cow 10 'searching for 0010 or 10 would be difficult and get false hits
'by keeping the leading zeros we can find the name "0010" 'if you want to make a number into a name do it this way c=10 name$=right$("0000"+str$(c),4) print "this cow's name is ";name$
'write to last record file as comma delimited with chr$(13)+chr$(10)as new line marker '#tocht "cow,"+ac$(i)+","+ag$(i)+","+ae$(i)+chr$(13)+chr$(10); print "cow,"+ac$(i)+","+ag$(i)+","+ae$(i)
'again by keeping the leading zeros we can more easily find the reading lastreading$="cow,"+ac$(i)+","+ag$(i)+","+ae$(i)
'is the cow reported in the last file print "searching for cow,";ac$(i) pos=instr(lastreading$,"cow,";ac$(i),1) if pos>0 then 'is the reading greater than last time? print val(ag$(i)) 'this code picks out the reading as the 9th character in each cows record print val(mid$(lastreading$,pos+9,1)) if val(ag$(i))>val(mid$(lastreading$,pos+9,1))then report=1 end if end if
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Apr 14, 2020 14:32:45 GMT -5
A few questions. I have also cownumbers with 4 digits, like 1134 how to do that and if possible that cow 1 stays 1 and not 0001? Thanks. Jack Holy cow how many milkers do you have?, smarter people that I can answer if there are any benefits with starting from starting with 0001
Me personally, I think a database should be your future goal.
I'm guessing for 10 months of the year a cow is giving milk and as you dry her off for mating again you need to start measuring activity again.
So why not keep data on each cow for the productive life of the cow. (could be 15 years plus) you may see patterns in the heat cycle that give you a heads up to how long after calving any particular cows cycles.
And which genetic line falls pregnant again the quickest.
Be a bit of a pain if the whole herd synchronise , poor Bulls . ( or you with the straws) Maybe there are advantages!
I guess a CSV file for each cow would still work but SQlite gives you big advantages for extracting queries.
35 years ago I had three jersey cows for home consumption (milk and meat)
Maybe dedicate some time to hand writing a complete database design. (maybe examples already exists)
stay focused...all the best
Haha Hi metro, not so much as you think But we get the numbers by the goverment and each year a new serie. Sometimes its starts with 9000 or now it was 1000. But we have our own numbers and also where the activitymeter is on. See this picture insert code here Cow transponderWe milk now 125 cows. We have software from that company: Here is everything what you see off the off activity. So I think I will not program it bij myself Thats to much for me. Problem with there software I was not happy with there alarm, so there for I want to make this sms alert. We do IA for breeding and use semen from Sweden. Good health breeding program. We are now in crisis through the corona, who not? I dont know how this end. We will see. We go on!!! Maybe I will make new plans for something. I should make photos off my system wil LB and the melkstable and arduino displays. Thanks
Jack
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Apr 14, 2020 14:37:43 GMT -5
Yes I would dearly like to re write the software with meaningful names and a dedicated database. However the thing works! horray! This would help get more consistent results, keeping the data as it is found. 'from the farm software file It would be best to keep the data unchanged ac$(i)="1234" 'cow 0001-9999 length always 4 ae$(i)="05" 'hour 00-99 length always 2 ag$(i)="3" 'reading 0-3 length always 1?
'don't change these strings keep them as strings in your process 'if you need to compare values use val(ac$(i)) but the cow number is really just a "name"
'the word "cow" helps find the cows name 'so searching for "cow,0010" reliably finds cow 10 'searching for 0010 or 10 would be difficult and get false hits
'by keeping the leading zeros we can find the name "0010" 'if you want to make a number into a name do it this way c=10 name$=right$("0000"+str$(c),4) print "this cow's name is ";name$
'write to last record file as comma delimited with chr$(13)+chr$(10)as new line marker '#tocht "cow,"+ac$(i)+","+ag$(i)+","+ae$(i)+chr$(13)+chr$(10); print "cow,"+ac$(i)+","+ag$(i)+","+ae$(i)
'again by keeping the leading zeros we can more easily find the reading lastreading$="cow,"+ac$(i)+","+ag$(i)+","+ae$(i)
'is the cow reported in the last file print "searching for cow,";ac$(i) pos=instr(lastreading$,"cow,";ac$(i),1) if pos>0 then 'is the reading greater than last time? print val(ag$(i)) 'this code picks out the reading as the 9th character in each cows record print val(mid$(lastreading$,pos+9,1)) if val(ag$(i))>val(mid$(lastreading$,pos+9,1))then report=1 end if end if
Thanks Rod. Sorry for the late responce. All problems with corona will take a lot off time. I hope the milk collection will go on. The software works great each day and do what is has to. Some times an error. I think with reading the first file. But now problem. Windows schedule runs it each half an hour. Thanks for all the help! Sure I will think someting news!!
|
|