|
Forum Index : Microcontroller and PC projects : DOW$ not working Picromite
| Page 1 of 2 |
|||||
| Author | Message | ||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Can anyone tell me why this won't work? I'm trying to print the day of the week but it always prints Saturday I've narrowed it down to the month not being processed right IF I comment out 'DOW$(0)="Sunday":DOW$(1)="Monday":DOW$(2)="Tuesday":DOW$(3)= "Wednesday":'DOW$(4)="Thursday":DOW$(5)="Friday":DOW$(6)="Saturday" then print DOW$ it prints a blank space I'm using a Picromite, what I don't get is I've used this code on the Explore 100 in the past and it worked The only "possible issue" I can see is if I PRINT month$ it prints 8 and not 08 but I can't see that causing an issue It's probably something stupid I've done but I cannot see what [code]DIM DOW$ DOW$(0)="Sunday":DOW$(1)="Monday":DOW$(2)="Tuesday":DOW$(3)= "Wednesday":DOW$(4)="Thursday":DOW$(5)="Friday":DOW$(6)="Saturday" Year=Val(Mid$(Date$,7,4)):Month=Val(Mid$(Date$,4,2)):Day=Val(Mid$(Date$,1,2)) print date$ print time$ print DOW$(DayOfWeek(Year, Month, Day)) Function DayOfWeek(year, month, day) a = Int((14-month)/12) m = month + 12*a - 2 y = year - a DayOfWeek = (day + y + Int(y/4)-Int(y/100)+Int(y/400)+Int(31*m/12)) Mod 7 End Function [/code] |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
You haven't dimensioned DOW$ should be DIM DOW$(6) |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
It's still giving the same result |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
![]() |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter, how come your's doesn't have spaces in the listing but mine does? there are no spaces in my code |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Your code has CR and LF at the end of lines. Linux expects just CR. You have commented out the lines setting up DOW$ This is better syntax anyway DIM DOW$(6)=("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Sorry Peter, I put the comment in when I was trying to find the error and wanted it to print the day numberal it's working now Thanks |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Trying it in the proper full code now it comes up with Error: Function or array DAYOFWEEK not declared you don't declare functions do you? |
||||
| PicFan Senior Member Joined: 18/03/2014 Location: AustriaPosts: 133 |
Did you declare a variable for the function's result? . . . DayOfWeek(Year, Month, Day) ERROR ! . . . x = DayOfWeek(Year, Month, Day) OK ! X = The result, the number from Day of week. Wolfgang |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I didn't realise I had to ... It's working now, coming up with the wrong day but it's got to be something I did so I should be able to get it Thanks |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Now it's doing the original problem which is why I tried the DOW function on its own with no program Now I've integrated it into the program I'm getting this AND the Pi crashes and I have to reboot The function is the same one I was using that worked [code] DIM DOW$(6)=("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") Year=Val(Mid$(Date$,7,4)):Month=Val(Mid$(Date$,4,2)):Day=Val(Mid$(Date$,1,2)) print DOW$(DayOfWeek(Year, Month, Day)) Function DayOfWeek(year, month, day) a = Int((14-month)/12) m = month + 12*a - 2 y = year - a DayOfWeek = (day + y + Int(y/4)-Int(y/100)+Int(y/400)+Int(31*m/12)) Mod 7 End Function[/code] |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
There is a known issue with the Pi-cromite that some, but not many, MMBasic errors cause a crash. I have been unable to track this down as is seems as though it is a compiler and/or linker error. The problem in your code is almost certainly that the function is returning a negative number or a number > 6 which causes the MMBasic error in the first place |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter Is there a way to keep the Picromite running when you close the terminal window? I've been using Putty to connect wirelessly but Ctrl Z won't work unless I stop the program with Ctrl C first If I just close Putty then it crashes |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Yes, but I didn't find the mechanism. Somewhere in one of the Pi-cromite threads one of the other Unix experts explained how to do it. You will have to search on Pi-cromite and spend time browsing |
||||
| disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 1044 |
Hi Lewis, During development I use the screen command as mentioned in a previous thread 'screen - provides terminal for current session so you can close putty. 'screen -D -r - lists screen sessions you can reconnect to So when you first login and before you start MMbasic type screen ... then do your command to start MMBasic as normal. If you close the terminal or it times out when you come back do screen -D -r ... this will reconnect to MMbasic I have not finished development, so screen is good for now, but the final solution so it just boots up and runs will use one of the following. Five other ways to do it Regards Gerry F4 H7FotSF4xGT |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Deleted - Google told me that I had to download screen |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Blit doesn't seem to be working properly? The "compass" is a picture and the arrow should only be showing one position ![]() |
||||
| Azure Guru Joined: 09/11/2017 Location: AustraliaPosts: 446 |
Lew, you'll need to provide a bit more information if you are expecting any suggestions or help on your last post. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
The protocol to make this work is: write the compass without a pointer BLIT READ area overlapping the complete compass, i.e. the compass background do option autorefresh off ' optional reduces artifacts BLIT WRITE compass background write the pointer option autorefresh on 'optional reduces artifacts refresh 'optional reduces artifacts loop |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I've finally got the Day of the Week working on the Picromite BUT it will not print on the display in the position and font I want it The 2 print statements work perfectly and if I print it in a different font and position it works Anyone got any ideas why not? [code] cls RGB(GREEN) dim DOW$,DOW_DAY$ DOW$(0)="Sunday":DOW$(1)="Monday":DOW$(2)="Tueday":DOW$(3)="Wednesday":DOW$(4)="Thursday":DOW$(5)="Friday":DOW$(6)="Sat" DOW_DAY$=DOW$(DayOfWeek(YEAR,MONTH,DAY)) print DOW_DAY$ Text 290,60,DOW_DAY$,LM,6,1,RGB(red),RGB(blue)'dow print DOW_DAY$ function DayOfWeek(year, month, day)c local a,m,y a = int((14-month)/12) m = month + 12*a - 2 y = year - a DayOfWeek = (day + y + int(y/4)-int(y/100)+int(y/400)+int(31*m/12)) mod 7 end function [/code] EDIT: It seems most fonts other than 6.1 work BUT FONT 6,1 works printing "DATE$" or "TIME$" |
||||
| Page 1 of 2 |
|||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |