02 Message

The message structure gets its name abbreviated to “ic-msg” because we type it a lot.

A IC-Msg is a structure.

(make-ic-msg Number Number Color-String)

Interpretation:

(make-ic-msg from to col)
  • from: the id of the world sending the message
  • to: the id of the world the message is intended for
  • col: the new color that world is to show

The structure definition for a message should go in a separate file so we can use advanced #lang racket features to make it simple to send.

Instructions

  1. Open a new, empty file (new tab; Control-T).

  2. Change the new file to Racket language mode. Go to the menu “Language”, select “Choose Language…” and then “The Racket Language”.

  3. The file should contain only these three lines below:

    #lang racket
    (provide (all-defined-out))
    (define-struct ic-msg (from to col) #:prefab)
    
  4. Save the file in the same folder that contains your other code. (This works like the posn-util.rkt file.)

After saving, verify that the file says “Determine language from source” in the bottom left part of the window. Not “Beginning Student”.

Common Problems

  • The file must be in Racket language mode. (Menu: Language -> Choose Language … -> The Racket Language)
  • There should be no space between the #: and prefab.
  • This file should not begin with (require picturing-programs).

If you have problems creating the file yourself, download it using Save link as… (ic-msg.rkt).

Last modified August 18, 2023: 2022-2023 End State (7352e87)