QB64 Phoenix Edition
BAM Sample Programs - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: QBJS, BAM, and Other BASICs (https://qb64phoenix.com/forum/forumdisplay.php?fid=50)
+--- Thread: BAM Sample Programs (/showthread.php?tid=1992)

Pages: 1 2 3 4


RE: BAM Sample Programs - CharlieJV - 09-13-2024

A "10PRINT" Variant, BAMified

   


RE: BAM Sample Programs - CharlieJV - 10-08-2024

Oriental Paintbrush Sim, a port of a QBJS program by Vince.

Kind of a fun thing for some mindless and minimalist doodling :


   


RE: BAM Sample Programs - TDarcos - 10-08-2024

(02-17-2024, 08:22 PM)CharlieJV Wrote: Latest batch of programs: Added 2024-02
Your "Which weekday" program https://basicanywheremachine.neocities.org/sample_programs/BAM_SamplePrograms?page=which_weekday has an error. Try the date 1-1-1800, which was a Wednesday. This program says it's Tuesday.

I have the same problem. I can never get any Zeller's congruence formulas to consistently produce correct results.


RE: BAM Sample Programs - SMcNeill - 10-08-2024

(10-08-2024, 06:36 PM)TDarcos Wrote:
(02-17-2024, 08:22 PM)CharlieJV Wrote: Latest batch of programs: Added 2024-02
Your "Which weekday" program https://basicanywheremachine.neocities.org/sample_programs/BAM_SamplePrograms?page=which_weekday has an error. Try the date 1-1-1800, which was a Wednesday. This program says it's Tuesday.

I have the same problem. I can never get any Zeller's congruence formulas to consistently produce correct results.

Code: (Select All)
Function GetWeekDay& (Day$) 'use MM/DD/YYYY format
    'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
    If CheckDayFormat(Day$) = 0 Then GetWeekDay = 0: Exit Function
    Dim As Long century, zerocentury, result
    Dim As Long MM, DD, YYYY
    MM = GetMonth(Day$): DD = GetDay(Day$): YYYY = GetYear(Day$)
    If MM < 3 Then MM = MM + 12: YYYY = YYYY - 1
    century = YYYY Mod 100
    zerocentury = YYYY \ 100
    result = (DD + Int(13 * (MM + 1) / 5) + century + Int(century / 4) + Int(zerocentury / 4) + 5 * zerocentury) Mod 7
    If result = 0 Then result = 7
    GetWeekDay& = result 'results are 1 to 7, from Sunday to Saturday
End Function

The above gives Wednesday as the proper result.  Use with the below for quick insertion of the weekday name:

Code: (Select All)
Function GetWeekDayName$ (Day$) 'use MM/DD/YYYY format
    Dim result As Long
    result = GetWeekDay(Day$)
    Select Case result
        Case 1: GetWeekDayName = "Sunday"
        Case 2: GetWeekDayName = "Monday"
        Case 3: GetWeekDayName = "Tuesday"
        Case 4: GetWeekDayName = "Wednesday"
        Case 5: GetWeekDayName = "Thursday"
        Case 6: GetWeekDayName = "Friday"
        Case 7: GetWeekDayName = "Saturday"
    End Select
End Function



RE: BAM Sample Programs - CharlieJV - 10-08-2024

(10-08-2024, 06:36 PM)TDarcos Wrote:
(02-17-2024, 08:22 PM)CharlieJV Wrote: Latest batch of programs: Added 2024-02
Your "Which weekday" program https://basicanywheremachine.neocities.org/sample_programs/BAM_SamplePrograms?page=which_weekday has an error. Try the date 1-1-1800, which was a Wednesday. This program says it's Tuesday.

I have the same problem. I can never get any Zeller's congruence formulas to consistently produce correct results.

Hey, thank-you much for catching that.

I replaced the algorithm with BASIC code from the "Doomsday rule" at Rosetta Code.

(You might have to refresh the page to get the old version out of your browser cache.)

Source code for the running program listed below the program.

(10-08-2024, 06:45 PM)SMcNeill Wrote:
(10-08-2024, 06:36 PM)TDarcos Wrote:
(02-17-2024, 08:22 PM)CharlieJV Wrote: Latest batch of programs: Added 2024-02
Your "Which weekday" program https://basicanywheremachine.neocities.org/sample_programs/BAM_SamplePrograms?page=which_weekday has an error. Try the date 1-1-1800, which was a Wednesday. This program says it's Tuesday.

I have the same problem. I can never get any Zeller's congruence formulas to consistently produce correct results.

Code: (Select All)
Function GetWeekDay& (Day$) 'use MM/DD/YYYY format
    'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
    If CheckDayFormat(Day$) = 0 Then GetWeekDay = 0: Exit Function
    Dim As Long century, zerocentury, result
    Dim As Long MM, DD, YYYY
    MM = GetMonth(Day$): DD = GetDay(Day$): YYYY = GetYear(Day$)
    If MM < 3 Then MM = MM + 12: YYYY = YYYY - 1
    century = YYYY Mod 100
    zerocentury = YYYY \ 100
    result = (DD + Int(13 * (MM + 1) / 5) + century + Int(century / 4) + Int(zerocentury / 4) + 5 * zerocentury) Mod 7
    If result = 0 Then result = 7
    GetWeekDay& = result 'results are 1 to 7, from Sunday to Saturday
End Function

The above gives Wednesday as the proper result.  Use with the below for quick insertion of the weekday name:

Code: (Select All)
Function GetWeekDayName$ (Day$) 'use MM/DD/YYYY format
    Dim result As Long
    result = GetWeekDay(Day$)
    Select Case result
        Case 1: GetWeekDayName = "Sunday"
        Case 2: GetWeekDayName = "Monday"
        Case 3: GetWeekDayName = "Tuesday"
        Case 4: GetWeekDayName = "Wednesday"
        Case 5: GetWeekDayName = "Thursday"
        Case 6: GetWeekDayName = "Friday"
        Case 7: GetWeekDayName = "Saturday"
    End Select
End Function

Thanks, Steve.  I wound up nabbing some "Doomsday rule" code from Rosetta code.  That little proggie I had done was meant to demonstrate how we can take some old BASIC code and "BAMify" it.


RE: BAM Sample Programs - CharlieJV - 10-19-2024

"PUT" Graphics Demo:  https://basicanywheremachine-news.blogspot.com/2024/10/put-graphics-demo-16-color.html