Giff Examples - Owen2k6/GoOS GitHub Wiki

Complete Examples

1) Simple Notepad

window Notepad {
  title "Notepad"; width 480; height 260; background "#FFFFFF"

  label head { y 6; text "Tiny Notepad"; textColour black; centre true }

  input filePath { x 10; y 32; width 300; height 20; text "0:\\note.txt" }
  input body     { x 10; y 60; width 460; height 150; text "" }

  button save { x 10; y 216; width 80; height 24; text "Save"
    onClick {
      fileWrite "$input_filePath_text", "$input_body_text";
      message "Saved to $input_filePath_text";
    }
  }

  button load { x 100; y 216; width 80; height 24; text "Load"
    onClick {
      fileRead "$input_filePath_text", filedata;
      set out = "$filedata";
      // crude echo back into the input by saving variable then reusing elsewhere
      message "Loaded (length $out)"; // show length via dialogue
    }
  }
}

2) HTTP fetch + persist

window Fetcher {
  title "Fetcher"; width 420; height 180; background "#F8F8F8"

  label info { x 10; y 10; text "Enter URL (http only)"; textColour black }
  input url  { x 10; y 28; width 300; text "http://example.com/" }

  button go {
    x 320; y 26; width 80; height 24; text "Fetch"
    onClick {
      netGetText "$input_url_text", page;
      if "$net_status == ok" {
        fileWrite "0:\\last.txt", "$page";
        message "OK ($net_size bytes). Saved to 0:\\last.txt";
      } else {
        message "Error: $net_status";
      }
    }
  }
}

3) Panels & variables

window PanelDemo {
  title "Panels"; width 360; height 200; background "#EFEFEF"

  panel left {
    x 0; y 0; width 140; height 200; background "#E2EAF7"
    label t { x 8; y 8; text "Options"; textColour black }
    button a { x 8; y 36; width 124; height 22; text "Alpha" }
    button b { x 8; y 62; width 124; height 22; text "Beta" }
  }

  label out { x 160; y 40; text "Press a button"; textColour black }

  button alpha {
    x 160; y 80; width 80; height 24; text "Say A"
    onClick { set msg = "Alpha pressed"; message "$msg"; }
  }
}
⚠️ **GitHub.com Fallback** ⚠️