Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:46 18 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SD Card

     Page 2 of 2    
Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1997
Posted: 09:05pm 04 Nov 2015
Copy link to clipboard 
Print this post

Thanks Grogs,
I think you misunderstood the next 8 files bit.
As you can see the first entry on each line is the day of the month so when we find the correct day I don't want to read the next 8 lines just the next 8 comma separated variables. The four figure values are the time in 24 hour mode and the decimal values are heights in metres. So on the TFT screen it shows the Tide Times and Heights for the day. The other thing is the year and month are deliberately Input as 015 and -10 so they are not confused with other data. When the Date gets to 2016 we have to search through all of 2015 data first to find the start of the 2016 year. So I don't know if you can use LINE INPUT for the year as if it is 2016
we have to look through the 2015 Data first. If you understand what I mean. The data for 2017 will also be there, and the device has to work when it is switched on at any time.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 09:14pm 04 Nov 2015
Copy link to clipboard 
Print this post

Yes, I did misunderstand the entries vs lines bit.

Hang on a tick, and I will try a modified code.....
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 10:03pm 04 Nov 2015
Copy link to clipboard 
Print this post

How about this, then?






START:
year$ = Right$(Date$,3)
month$ = Mid$(Date$,3,3)
days$ = Left$(Date$,2)
day = Val(days$)
Open "paul.dat" For input As #1
Print "DAY/MONTH/YEAR:"
Print days$,month$,year$
Print "Searching for year...";

Do 'look through the data for the year eg: "015"
Line Input #1,year2$
If Mid$(year2$,2,3) = year$ Then
Print "(OK)"
Exit Do
EndIf
Loop
Print "Searching for month...";
Do
Line Input #1,month2$ 'look through the data for the month eg: -10
If Mid$(month2$,2,3) = month$ Then
Print "(OK)"
Exit Do
EndIf
Loop
Print "Searching for day...";
Do ' look through the data for the correct day
Line Input #1,day2$
If Mid$(day2$,2,1)="," Then
daze$="0"+day2$
Else
daze$=day2$
EndIf
If Mid$(daze$,1,2)=days$ Then
Print "(OK)"
Exit Do
EndIf
Loop

'At this point, we should be at the right place in the datafile
Print "Dataset found:"
Print daze$

X=1:Y=0
Dim VALUE(8)
Do
Do
BITE$=Mid$(daze$,X,1)
If BITE$="," Or X>75 Then Exit Do
DAT$=DAT$+BITE$
X=X+1
Loop
VALUE(Y)=Val(DAT$)
Y=Y+1:X=X+1:DAT$=""
If Y=9 Then Exit Do
Loop
For X=0 To 8
Print VALUE(X)
Next




End



For X=1 To 8
If Eof(#1)<>0 Then
Print "End of datafile!"
Exit For
EndIf
Line Input #1,L$
Print L$
Next
Print:Print "Done."
Close #1
End

Smoke makes things work. When the smoke gets out, it stops!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2948
Posted: 10:16pm 04 Nov 2015
Copy link to clipboard 
Print this post

Has it been confirmed (with Geoff?) that using INPUT by itself is a 'bug'?
I am unable to test this myself as not currently near any MM's.

 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1997
Posted: 10:17pm 04 Nov 2015
Copy link to clipboard 
Print this post

Thanks Grogs leave it at that for now and I'll work on it but I still want to know why I can't use INPUT #1,X$ and have to use LINE INPUT.
Paul.

Edit @ WW you posted at the same time as me, If I could use INPUT #1, I don't think I would have a problem writing the code.Edited by palcal 2015-11-06
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1997
Posted: 11:22pm 04 Nov 2015
Copy link to clipboard 
Print this post

Yipee!! finally having success using the INPUT #1, X$ command.
not perfect yet but working.
My head is spinning will post back again tomorrow, time permitting.

Paul.

Edit:
Grogster.. have a look at my code I inadvertently had a $ sign after my first INPUT command. ie: INPUT$ #1, sorry for all the wasted time but I guess it happens.
Don't know why it didn't throw a syntax error.Edited by palcal 2015-11-06
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1997
Posted: 01:11pm 05 Nov 2015
Copy link to clipboard 
Print this post

OK thanks for the help and wasting your time, but I have learnt a lot.
I now have the code working perfectly. The only problem I had, was using INPUT #1 when it inputs the first variable on a line I expected the pointer to move to the next variable but it moves to the next line. But that was easily overcome by inputting the entire line.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 02:31pm 05 Nov 2015
Copy link to clipboard 
Print this post

Ahhh - that would explain the "Line is too long." errors I kept getting when trying something like INPUT #1,A,B,C,D. The manual suggests that you can read multiple comma-separated values in one command, but that is obviously not the case.

It gave me a chance to play around with extracting data from a string, and ramming it into an array, so it was all good for me.
Smoke makes things work. When the smoke gets out, it stops!
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025