' xprint_certificate.pb — Certificate printing layout simulation
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL certID AS LONG
    LOCAL recipientID AS LONG
    LOCAL courseID AS LONG
    LOCAL completionDate AS LONG
    LOCAL recipientName AS STRING
    LOCAL courseName AS STRING
    LOCAL orgName AS STRING
    LOCAL borderWidth AS LONG
    LOCAL textSize AS LONG
    LOCAL numCerts AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL totalCerts AS LONG
    LOCAL maxCerts AS LONG
    LOCAL score AS LONG
    LOCAL hoursCompleted AS LONG
    LOCAL gradeStr AS STRING
    LOCAL dateStr AS STRING
    LOCAL numStr AS STRING

    maxCerts = 4
    orgName = "PBXB64 Training Institute"

    PRINT "=== Certificate Generation ==="

    FOR totalCerts = 1 TO maxCerts
        certID = 1000 + totalCerts
        recipientID = totalCerts
        courseID = totalCerts MOD 3
        completionDate = 20260601 + totalCerts
        score = 80 + totalCerts * 5
        hoursCompleted = 20 + totalCerts * 10

        IF recipientID = 1 THEN recipientName = "Alice Johnson"
        IF recipientID = 2 THEN recipientName = "Bob Smith"
        IF recipientID = 3 THEN recipientName = "Carol Davis"
        IF recipientID = 4 THEN recipientName = "David Wilson"

        IF courseID = 0 THEN courseName = "C Programming Fundamentals"
        IF courseID = 1 THEN courseName = "PowerBASIC Mastery"
        IF courseID = 2 THEN courseName = "Assembly Language"

        IF score >= 90 THEN gradeStr = "A"
        IF score >= 80 AND score < 90 THEN gradeStr = "B"
        IF score >= 70 AND score < 80 THEN gradeStr = "C"
        IF score < 70 THEN gradeStr = "D"

        PRINT "  +" + STRING$(60, "=") + "+"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |" + STRING$(20, " ") + "CERTIFICATE OF COMPLETION" + STRING$(20, " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  This certifies that" + STRING$(37, " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  " + recipientName + STRING$(54 - LEN(recipientName), " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  has completed the course:" + STRING$(33, " ") + "|"
        PRINT "  |  " + courseName + STRING$(54 - LEN(courseName), " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  Score: " + STR$(score) + "%  Grade: " + gradeStr + STRING$(40 - LEN(STR$(score)) - LEN(gradeStr), " ") + "|"
        PRINT "  |  Date: " + STR$(completionDate) + STRING$(46, " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  Certificate #" + STR$(certID) + STRING$(46 - LEN(STR$(certID)), " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  |  " + orgName + STRING$(54 - LEN(orgName), " ") + "|"
        PRINT "  |" + STRING$(58, " ") + "|"
        PRINT "  +" + STRING$(60, "=") + "+"
    NEXT totalCerts

    PRINT "Total certificates: " + STR$(maxCerts)
    PRINT "=== End Certificate ==="
    FUNCTION = 0
END FUNCTION
