Simple Guess Demo

Where is the Delphi?

Its still all TypeScript, but in the end you will be able to do this in Delphi, TypeScript, or both. Right now we are still focusing on the client side libraries. We have done some Delphi back end integration and will be continuing on that soon.

Please keep in mind that while Delphi will be our focus to integrate with existing IntraWeb code, IntraWeb 17 can be used with any backend, Delphi or not.

Plain Vanilla

Yes, its plain vanilla looking. IntraWeb 17 supports full styling, but for now we are focusing on functionality.

Running in Browser

IWML

ACORN 1.0 IWML 1.0
Guess.Index
  FocusControl: GuessEdit
  ActionControl: GuessButton
  Root[]
    SimpleStack[]
      Edit:GuessEdit =this.Guess
      Text:MsgText;
      Text Guess #[=this.Count]
      Button:GuessButton Guess
    ]
  ]
]

TypeScript

namespace Guess {
  export class IndexGen extends IntraWeb.Code {
    public GuessButton: IntraWeb.Controls.Button = null;
    public GuessEdit: IntraWeb.Controls.Edit = null;
    public MsgText: IntraWeb.Controls.Text = null;
  }

  export class Index extends IndexGen {
    public Count = 0;

    public Guess = NaN;
    protected MagicNo = Math.floor((Math.random() * 100) + 1);

    public Page_AfterLoad(): void {
      const xMagicNo = this._Page.WebParam("MagicNo");
      if (xMagicNo) {
        this.MagicNo = parseInt(xMagicNo, 10);
      }
    }

    public Event_GuessButton_Click(aSender: object, e: MouseEvent): void {
      if (e.shiftKey) {
        IntraWeb.Dialogs.MessageBox("The magic number is: " + this.MagicNo);
        return;
      }

      let xMsg: string = null;

      if (isNaN(this.Guess)) {

        xMsg = this.GuessEdit.Text.Value + " is not a valid number.";
      } else if (this.Guess < 1 || this.Guess > 100) {
        xMsg = this.Guess + " is not in the range of 1 to 100.";
      } else {
        this.Count++;

        if (this.Guess < this.MagicNo) { xMsg = this.Guess + " is too low."; } else if (this.Guess > this.MagicNo) {
          xMsg = this.Guess + " is too high.";
        } else if (this.Guess === this.MagicNo) {
          IntraWeb.Dialogs.MessageBox("Congratulations! You guessed the magic number.");
          this.GuessButton.Enabled.Value = false;
        }
      }

      if (xMsg) {
        this.MsgText.Text.Value = xMsg;
      }
      this.Guess = NaN;
      this.GuessEdit.Focus();
    }
  }
}