GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

🌸 GOLF(2gg) β€” the start-loop page, bestie edition 🌸

okay so you opened the manual for start-loop from GOLF(2gg) (that's the Development section btw) and honestly? iconic choice. let's get into it πŸ’…


✨ NAME ✨

start-loop β€” like, it's a program-flow thing πŸ¦‹


πŸŽ€ PURPOSE πŸŽ€

Loop execution based on a condition. that's it, that's the vibe. πŸ”


🫢 SYNTAX 🫢

    start-loop  [ repeat <repeat> ] \
        [ use <loop counter> \
            [ start-with <start with> ] [ add <add> ] ]

        <any code>

    end-loop

πŸ’– DESCRIPTION πŸ’–

so start-loop will execute the code sitting between the start-loop and end-loop clauses a certain number of times, based on the condition you specified β€” and also based on how you use continue-loop and break-loop, which you're allowed to drop in-between those two. 🧚

the <repeat> number (in the repeat clause) says how many times to execute the loop β€” barring use of continue-loop and break-loop, ofc. ✨

the <loop counter> (in the use clause) is a number that by default starts with the value of 1, and gets incremented by 1 each time execution loops back to start-loop, unless the start-with and/or add clauses are used. and listen β€” the end value of <loop counter> (right when you're just outside end-loop) is the first value past the last loop. periodt. πŸ‘‘

if <start with> (in the start-with clause) is used, that's the initial value for <loop counter> instead of the default 1. and if <add> is specified (in the add clause), then <loop counter> is incremented by <add> each time execution loops back to start-loop β€” instead of the default 1. <add> can be positive or negative, so go off, do your thing. πŸ“

⚠️ if either of the start-with or add clauses is used, then use must be specified. no cap, no exceptions.

🌈 EXAMPLES 🌈

    start-loop repeat 20 use p start-with 0
        print-out p
        @
    end-loop

a loop controlled via continue-loop and break-loop statements, displaying numbers from 1 through 30 but omitting those divisible with 3 πŸ¦‹

    set-number n
    set-number max = 30
    start-loop
        set-number n add 1
        if-true n every 3
            continue-loop
        end-if
        if-true n greater-than max
            break-loop
        end-if
        print-out n
    end-loop

πŸ‘€ SEE ALSO πŸ‘€

Program flow πŸŒ€

break-loop call-handler code-blocks continue-loop do-once exit-handler if-defined if-true quit-process return-handler start-loop See all documentation


and that's the whole page bestie, you ate that 🫢

this lil gem is from $VERSION and it's dated $DATE β€” it lives in GOLF(2gg), go forth and loop responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from