Differences between revisions 2 and 3
Revision 2 as of 2008-02-26 14:04:27
Size: 527
Editor: anonymous
Comment:
Revision 3 as of 2008-02-26 14:22:44
Size: 1306
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:

Line 2: Line 4:
 HelloWorld;ref;btn;myFnt HelloWorld;ref;btn;myFnt
Line 4: Line 6:
 ref←⎕NEW'Form'(⊂'Caption' 'Hello World with APL')
 ref.Coord←'Pixel'
 myFnt←⎕NEW'Font'(('Pname' 'Arial Black')('Size' 48))
 btn←ref.⎕NEW'Button'(('Caption' 'Hello World')('Posn'(0 0))('Size'ref.Size))
 btn.FontObj←myFnt
 btn.onSelect←1
 ⎕DQ'.'

 ref←⎕NEW⊂'Form' ⍝ Create a form with default parameters
 ref.Caption←'Hello World with APL' ⍝ Set the caption
 ref.Coord←'Pixel' ⍝ Deal with pixels

 myFnt←⎕NEW⊂'Font' ⍝ Create a font
 myFnt.Pname←'Arial Black' ⍝ Which one
 myFnt.Size←48 ⍝ Setting the font size

 btn←ref.⎕NEW⊂'Button' ⍝ Create a button
 btn.Caption←'Hello World' ⍝ Set the caption of the button
 btn.Posn←0 0 ⍝ Set the position of the button
 btn.Size←ref.Size ⍝ Make the button the same size as the form
 btn.FontObj←myFnt ⍝ Associated the font with the button
 btn.onSelect←1 ⍝ Interrupt when button is presssed

 ⎕DQ'.' ⍝ Give control to the user
Line 13: Line 25:
This is inline {{{⎕LX←'HelloWorld'}}} APL By setting the system variable {{{⎕LX}}} to {{{'HelloWorld'}}} we make sure that this code is executed automatically as soon as our program is loaded by APL.

HelloWorld;ref;btn;myFnt
⍝ Build up a GUI and display "Hello world" in a button on a Form

 ref←⎕NEW⊂'Form'                      ⍝ Create a form with default parameters
 ref.Caption←'Hello World with APL'   ⍝ Set the caption
 ref.Coord←'Pixel'                    ⍝ Deal with pixels

 myFnt←⎕NEW⊂'Font'                    ⍝ Create a font
 myFnt.Pname←'Arial Black'            ⍝ Which one
 myFnt.Size←48                        ⍝ Setting the font size

 btn←ref.⎕NEW⊂'Button'                ⍝ Create a button
 btn.Caption←'Hello World'            ⍝ Set the caption of the button
 btn.Posn←0 0                         ⍝ Set the position of the button
 btn.Size←ref.Size                    ⍝ Make the button the same size as the form
 btn.FontObj←myFnt                    ⍝ Associated the font with the button
 btn.onSelect←1                       ⍝ Interrupt when button is presssed

 ⎕DQ'.'                               ⍝ Give control to the user

By setting the system variable ⎕LX to 'HelloWorld' we make sure that this code is executed automatically as soon as our program is loaded by APL.

This program will result in this form:

attachment:helloworld.jpg

CategoryHelloWorld

HelloWorldGui (last edited 2014-02-17 10:22:17 by KaiJaeger)