Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:20 11 Nov 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 : DOW$ not working Picromite

     Page 1 of 2    
Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 08:10am 17 Aug 2018
Copy link to clipboard 
Print this post

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]Edited by lew247 2018-08-18
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 08:12am 17 Aug 2018
Copy link to clipboard 
Print this post

You haven't dimensioned DOW$

should be

DIM DOW$(6)
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 08:26am 17 Aug 2018
Copy link to clipboard 
Print this post

It's still giving the same result
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 08:39am 17 Aug 2018
Copy link to clipboard 
Print this post



 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 08:59am 17 Aug 2018
Copy link to clipboard 
Print this post



Peter, how come your's doesn't have spaces in the listing but mine does?
there are no spaces in my code
Edited by lew247 2018-08-18
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 09:11am 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 09:17am 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 10:42am 17 Aug 2018
Copy link to clipboard 
Print this post

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: Austria
Posts: 133
Posted: 11:16am 17 Aug 2018
Copy link to clipboard 
Print this post

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.

WolfgangEdited by PicFan 2018-08-18
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 11:49am 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 12:28pm 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 01:44pm 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 08:15pm 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 09:51pm 17 Aug 2018
Copy link to clipboard 
Print this post

  Quote  Is there a way to keep the Picromite running when you close the terminal window?


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: Australia
Posts: 1044
Posted: 11:56pm 17 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 05:22pm 18 Aug 2018
Copy link to clipboard 
Print this post

Deleted - Google told me that I had to download screen Edited by lew247 2018-08-20
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 06:28am 20 Aug 2018
Copy link to clipboard 
Print this post

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: Australia
Posts: 446
Posted: 07:39am 20 Aug 2018
Copy link to clipboard 
Print this post

  Quote  Blit doesn't seem to be working properly?

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 Kingdom
Posts: 10572
Posted: 08:25am 20 Aug 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1702
Posted: 06:59pm 01 Sep 2018
Copy link to clipboard 
Print this post

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$"Edited by lew247 2018-09-03
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025