' xprint_envelope.pb — Envelope printing layout simulation
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL senderName AS STRING
    LOCAL senderStreet AS STRING
    LOCAL senderCity AS STRING
    LOCAL senderZip AS LONG
    LOCAL recipientID AS LONG
    LOCAL recipientName AS STRING
    LOCAL recipientStreet AS STRING
    LOCAL recipientCity AS STRING
    LOCAL recipientZip AS LONG
    LOCAL envSize AS LONG
    LOCAL numEnvelopes AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL returnX AS LONG
    LOCAL returnY AS LONG
    LOCAL addrX AS LONG
    LOCAL addrY AS LONG
    LOCAL stampX AS LONG
    LOCAL stampY AS LONG
    LOCAL envWidth AS LONG
    LOCAL envHeight AS LONG
    LOCAL totalPrinted AS LONG
    LOCAL iter AS LONG
    LOCAL maxEnvelopes AS LONG
    LOCAL textStr AS STRING

    maxEnvelopes = 5
    senderName = "John Doe"
    senderStreet = "123 Main Street"
    senderCity = "Anytown, CA 90210"
    senderZip = 90210

    PRINT "=== Envelope Printing ==="
    PRINT "Size: #10 (4.125 x 9.5 inches)"

    FOR iter = 1 TO maxEnvelopes
        recipientID = iter

        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 recipientID = 5 THEN recipientName = "Eve Martin"

        IF recipientID = 1 THEN recipientStreet = "456 Oak Ave"
        IF recipientID = 2 THEN recipientStreet = "789 Pine Road"
        IF recipientID = 3 THEN recipientStreet = "321 Elm Street"
        IF recipientID = 4 THEN recipientStreet = "654 Maple Drive"
        IF recipientID = 5 THEN recipientStreet = "987 Birch Lane"

        IF recipientID = 1 THEN recipientCity = "Springfield, IL 62701"
        IF recipientID = 2 THEN recipientCity = "Portland, OR 97201"
        IF recipientID = 3 THEN recipientCity = "Austin, TX 73301"
        IF recipientID = 4 THEN recipientCity = "Denver, CO 80201"
        IF recipientID = 5 THEN recipientCity = "Miami, FL 33101"

        IF recipientID = 1 THEN recipientZip = 62701
        IF recipientID = 2 THEN recipientZip = 97201
        IF recipientID = 3 THEN recipientZip = 73301
        IF recipientID = 4 THEN recipientZip = 80201
        IF recipientID = 5 THEN recipientZip = 33101

        PRINT "--- Envelope #" + STR$(iter) + " ---"
        PRINT "Return: " + senderName + ", " + senderStreet
        PRINT "     " + senderCity
        PRINT "To: " + recipientName
        PRINT "    " + recipientStreet
        PRINT "    " + recipientCity
        PRINT "Stamp: top-right corner"
        totalPrinted = totalPrinted + 1
    NEXT iter

    PRINT "Total envelopes: " + STR$(totalPrinted)
    PRINT "=== End Envelope ==="
    FUNCTION = 0
END FUNCTION
