Jump to content

Search the Community

Showing results for tags 'if*'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome To Opusmodus
    • Announcements
    • Pre Sales Questions
  • Support Forum
    • Support & Troubleshooting
    • OMN Lingo
    • Function Examples
    • Score and Notation
    • Live Coding Instrument
    • Library Setup
    • MIDI Setup
  • Question & Answer
    • Suggestions & Ideas
  • Sharing
    • Made In Opusmodus
    • User Extensions Source Code

Blogs

  • Stephane Boussuge
  • Didier Debril

Categories

  • OMN The Language
  • Tutorial Guide
  • CLM Examples

Categories

  • Getting Started
  • HowTo
  • Live Coding
  • Music Theory and Analysis
  • Users Examples

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Gender


Location


Interests


About Me

Found 1 result

  1. Opusmodus 1.1.1.8740 New macro IF* added to Opusmodus system. The IF* (public domain) macro used in Allegro: if* Arguments: (test-form {then then-form+ | thenret} {elseif else-test-form {then else-then-form+ | thenret}}* [else else-form+]) This form consists of a series of clauses introduced by the symbols then, elseif, else, and thenret. First the predicate test-form is evaluated. If it is true, the then-forms are evaluated, and the value of the last such form is returned. If test-form evaluates to nil, any remaining clauses are processed. If no clauses remain, if* returns nil. When a thenret clause is encountered no further evaluation takes place, and the value of the most recently evaluated test-form is returned. When an elseif clause is encountered, the predicate else-test-form is evaluated. If it is true, the else-then-forms are evaluated, and the value of the last such form is returned; otherwise any remaining clauses are processed. If no clauses remain, if* returns nil. And lastly, when an else clause is encountered, the else-forms are evaluated, and the value of the last such form is returned. Examples ;; The basic format of a IF* expression is: ;; ;; (if* [test] then [do this 1] [do this 2] else [do other 1] [do other 2]) ;; ;; When [test] is true, the forms after the THEN are evaluated and the ;; result of the last returned; if [test] if false, the forms after the ;; ELSE are evaluated and the result of the last is returned. ;; So: (if* (> 3 2) then "three is bigger" 3 else "three is smaller" 2) => 3 ;; Your do not need an ELSE form: (if* (> 3 2) then "three is bigger" 3) => 3 (if* (> 2 3) then "two is bigger" 2) => nil ;; You can have multiple fors after THEN or ELSE: (defun foo (x) (if* x then (setq y 2) (print x) else (setq y -2) "no")) (foo 2) => 2 (foo "hello") => "hello" "hello" (foo nil) => "no" ;; There are two more special symbols: THENRET and ELSEIF. ;; THENRET says when the test is true just return the value of the test ;; form just evaluated: (if* (+ 4 5) thenret) => 9 ;; ELSEIF introduces a new test, so you can have compound tests: (setq score 77) (if* (< score 60) then "F" elseif (< score 70) then "D" elseif (< score 80) then "C" elseif (< score 90) then "B" else "A") => "C" (setq score 55) (if* (< score 60) then "F" elseif (< score 70) then "D" elseif (< score 80) then "C" elseif (< score 90) then "B" else "A") => "F" (setq score 92) (if* (< score 60) then "F" elseif (< score 70) then "D" elseif (< score 80) then "C" elseif (< score 90) then "B" else "A") => "A"
×
×
  • Create New...