~ubuntu-branches/ubuntu/lucid/kde-l10n-nl/lucid-proposed

« back to all changes in this revision

Viewing changes to docs/kdeedu/kturtle/programming-reference.docbook

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2009-01-29 22:37:38 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090129223738-zjekp5fzam8sv1he
Tags: 4:4.2.0-0ubuntu1
* New upstream release
* Bump version requirements of kdelibs5(-dev) to 4:4.2.0-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
>.</para>
93
93
</sect2>
94
94
 
 
95
<!-- constants like pi? -->
 
96
 
95
97
<sect2 id="string">
96
98
<title
97
99
>Tekenreeksen</title>
127
129
<title
128
130
>Namen</title>
129
131
<para
130
 
>Je kunt met de programmeertaal &turtlelang; nieuwe dingen maken. Als je een programma schrijft zul je vaak <link linkend="containers"
131
 
>plaatshouders</link
132
 
> nodig hebben, en in sommige gevallen heb je het commando <link linkend="learn"
133
 
>leer</link
134
 
> nodig om nieuwe commando's te maken. Als je een <link linkend="containers"
135
 
>plaatshouder</link
136
 
> of een nieuw commando met behulp van <link linkend="learn"
137
 
>leer</link
138
 
> maakt, dan moet je er een naam aan geven.</para>
 
132
>When using the &turtlelang; programming language you create new things. If you write a program you will often need <link linkend="containers"
 
133
>containers</link
 
134
> and in some cases you need <link linkend="learn"
 
135
>learn</link
 
136
> to create new commands. When making a new command with <link linkend="learn"
 
137
>learn</link
 
138
> you will have to specify a name.</para>
139
139
<para
140
 
>Je kunt een willekeurige naam kiezen, als die maar niet al wordt gebruikt. Bijvoorbeeld, je kunt een plaatshouder niet <link linkend="forward"
141
 
>vooruit</link
142
 
> noemen, omdat die naam al wordt gebruikt voor een commando, en dus al een betekenis heeft. <screen>
143
 
# hier wordt vooruit gebruikt als een plaatshouder, maar die heeft al een betekenis
144
 
# dus komt er een foutmelding:
145
 
$vooruit = 20
 
140
>You can choose any name, as long as it does not already have a meaning. For instance you cannot name a function <link linkend="forward"
 
141
>forward</link
 
142
>, since that name is already used for an internal command. <screen>
 
143
# here forward is used as a new command, 
 
144
# but it already has a meaning so 
 
145
# this will produce an error:
 
146
learn forward {
 
147
  print "this is invalid"
 
148
}
146
149
 
147
 
# dit werkt echter wel (is een commando):
148
 
vooruit 20
 
150
# this works:
 
151
learn myforward {
 
152
  print "this is ok"
 
153
}
149
154
</screen
150
 
> Namen mogen alleen letters, cijfers en onderstreepjes (_) bevatten. Ze moeten altijd met een letter beginnen. </para>
 
155
> Names can contain only letters, numbers and underscores (_). Yet they have to start with a letter. Container names have to start with the container prefix ($). <screen
 
156
># here forward is used as a container, 
 
157
# starting with the $ prefix, so it does
 
158
# not conflict with the forward command
 
159
$forward = 20
 
160
print $forward
 
161
</screen>
 
162
</para>
151
163
<para
152
164
>Plaatshouders worden <glossterm
153
165
>geaccentueerd</glossterm
197
209
<title
198
210
>Rekensymbolen</title>
199
211
<para
200
 
>&kturtle; kent alle basissymbolen van het rekenen: optellen (<userinput
 
212
>&kturtle; supports all basic math symbols: add (<userinput
201
213
>+</userinput
202
 
>), aftrekken (<userinput
 
214
>), subtract (<userinput
203
215
>-</userinput
204
 
>), vermenigvuldigen (<userinput
 
216
>), multiply (<userinput
205
217
>*</userinput
206
 
>), delen <userinput
 
218
>), divide (<userinput
207
219
>/</userinput
208
 
>) en de haakjes <userinput
 
220
>) and the brackets <userinput
209
221
>(</userinput
210
 
> en <userinput
 
222
> and <userinput
211
223
>)</userinput
212
224
>.</para>
213
225
<para
284
296
>De schildpad voortbewegen</title>
285
297
<para
286
298
>Er zijn verschillende commando's waarmee je de schildpad over het scherm kunt bewegen.</para>
287
 
  
288
 
<sect3 id="forward">
289
 
  <title
290
 
>vooruit (vt)</title>
 
299
 
291
300
  <variablelist>
 
301
    <anchor id="forward"/>
292
302
    <varlistentry
293
303
294
304
      <term
295
 
>vooruit</term>
 
305
>forward (fw)<indexterm
 
306
><primary
 
307
>forward (fw)</primary
 
308
></indexterm
 
309
></term>
296
310
      <listitem
297
311
><para
298
312
><screen
307
321
></listitem>
308
322
    </varlistentry>
309
323
  </variablelist>
310
 
</sect3>
311
 
<sect3 id="backward">
312
 
  <title
313
 
>achteruit (at)</title>
314
324
  <variablelist>
 
325
    <anchor id="backward"/>
315
326
    <varlistentry
316
327
>  
317
328
      <term
318
 
>achteruit</term>
 
329
>backward (bw)<indexterm
 
330
><primary
 
331
>backward (bw)</primary
 
332
></indexterm
 
333
></term>
319
334
      <listitem
320
335
><para
321
336
><screen
330
345
></listitem>
331
346
    </varlistentry>
332
347
  </variablelist>
333
 
</sect3>
334
 
<sect3 id="turnleft">
335
 
  <title
336
 
>draailinks (dl)</title>
337
348
  <variablelist>
 
349
    <anchor id="turnleft"/>
338
350
    <varlistentry
339
351
340
352
      <term
341
 
>draailinks</term>
 
353
>turnleft (tl)<indexterm
 
354
><primary
 
355
>turnleft (tl)</primary
 
356
></indexterm
 
357
></term>
342
358
      <listitem
343
359
><para
344
360
><screen
353
369
></listitem>
354
370
    </varlistentry>
355
371
  </variablelist>
356
 
</sect3>
357
 
<sect3 id="turnright">
358
 
  <title
359
 
>draairechts (dr)</title>
360
372
  <variablelist>
 
373
    <anchor id="turnright"/>
361
374
    <varlistentry
362
375
363
376
      <term
364
 
>draairechts</term>
 
377
>turnright (tr)<indexterm
 
378
><primary
 
379
>turnright (tr)</primary
 
380
></indexterm
 
381
></term>
365
382
      <listitem
366
383
><para
367
384
><screen
368
385
>draairechts X</screen>
369
386
<userinput
370
 
>draairechts</userinput
371
 
> laat de schildpad X graden naar rechts draaien. <userinput
372
 
>draairechts</userinput
373
 
> kun je afkorten met <userinput
374
 
>dr</userinput
 
387
>turnright</userinput
 
388
> the turtle to turn an amount of X degrees to the right. <userinput
 
389
>turnright</userinput
 
390
> can be abbreviated to <userinput
 
391
>tr</userinput
375
392
>.</para
376
393
></listitem>
377
394
    </varlistentry>
378
395
  </variablelist>
379
 
</sect3>
380
 
<sect3 id="direction">
381
 
  <title
382
 
>richting (rt)</title>
383
396
  <variablelist>
 
397
    <anchor id="direction"/>
384
398
    <varlistentry
385
399
386
400
      <term
387
 
>richting</term>
 
401
>direction (dir)<indexterm
 
402
><primary
 
403
>direction (dir)</primary
 
404
></indexterm
 
405
></term>
388
406
      <listitem
389
407
><para
390
408
><screen
399
417
></listitem>
400
418
    </varlistentry>
401
419
  </variablelist>
402
 
</sect3>
403
 
<sect3 id="center">
404
 
  <title
405
 
>thuis</title>
406
420
  <variablelist>
 
421
    <anchor id="center"/>
407
422
    <varlistentry
408
423
409
424
      <term
410
 
>thuis</term>
 
425
>thuis<indexterm
 
426
><primary
 
427
>center</primary
 
428
></indexterm
 
429
></term>
411
430
      <listitem
412
431
><para
413
432
><screen
418
437
></listitem>
419
438
    </varlistentry>
420
439
  </variablelist>
421
 
</sect3>
422
 
<sect3 id="go">
423
 
  <title
424
 
>ganaar</title>
425
440
  <variablelist>
 
441
    <anchor id="go"/>
426
442
    <varlistentry
427
443
428
444
      <term
429
 
>ganaar</term>
 
445
>ganaar<indexterm
 
446
><primary
 
447
>go</primary
 
448
></indexterm
 
449
></term>
430
450
      <listitem
431
451
><para
432
452
><screen
433
453
>ganaar X,Y</screen>
434
454
<userinput
435
 
>ganaar X,Y</userinput
436
 
> laat de schildpad naar een bepaalde plaats op het canvas gaan. De plaats is op X <glossterm linkend="pixels"
437
 
>pixels</glossterm
438
 
> vanaf de linkerkant en Y <glossterm linkend="pixels"
439
 
>pixels</glossterm
440
 
> vanaf de bovenkant van het canvas. Opmerking: de schildpad tekent met het commando <userinput
441
 
>ganaar</userinput
442
 
> geen lijn.</para
 
455
>go</userinput
 
456
> commands the turtle to go to a certain place on the canvas. This place is X <glossterm linkend="pixels"
 
457
>pixels</glossterm
 
458
> from the left of the canvas, and Y <glossterm linkend="pixels"
 
459
>pixels</glossterm
 
460
> form the top of the canvas. </para
443
461
></listitem>
444
462
    </varlistentry>
445
463
  </variablelist>
446
 
</sect3>
447
 
<sect3 id="gox">
448
 
  <title
449
 
>ganaarx</title>
450
464
  <variablelist>
 
465
    <anchor id="gox"/>
451
466
    <varlistentry
452
467
453
468
      <term
454
 
>ganaarx</term>
 
469
>ganaarx<indexterm
 
470
><primary
 
471
>gox</primary
 
472
></indexterm
 
473
></term>
455
474
      <listitem
456
475
><para
457
476
><screen
468
487
></listitem>
469
488
    </varlistentry>
470
489
  </variablelist>
471
 
</sect3>
472
 
<sect3 id="goy">
473
 
  <title
474
 
>ganaary</title>
475
490
  <variablelist>
 
491
    <anchor id="goy"/>
476
492
    <varlistentry
477
493
478
494
      <term
479
 
>ganaary</term>
 
495
>ganaary<indexterm
 
496
><primary
 
497
>goy</primary
 
498
></indexterm
 
499
></term>
480
500
      <listitem
481
501
><para
482
502
><screen
493
513
></listitem>
494
514
    </varlistentry>
495
515
  </variablelist>
496
 
</sect3>
 
516
  <note
 
517
><para
 
518
>Using the commands <userinput
 
519
>go</userinput
 
520
>, <userinput
 
521
>gox</userinput
 
522
>, <userinput
 
523
>goy</userinput
 
524
> and <userinput
 
525
>center</userinput
 
526
> the turtle will not draw a line, no matter if the pen is up or down.</para>
 
527
  </note>
 
528
</sect2>
 
529
 
 
530
<sect2 id="locate-the-turtle">
 
531
<title
 
532
>Where is the turtle?</title>
 
533
<para
 
534
>There are two commands which return the position of the turtle on the screen.</para>
 
535
 
 
536
  <variablelist>
 
537
    <anchor id="getx"/>
 
538
    <varlistentry
 
539
 
540
      <term
 
541
>getx<indexterm
 
542
><primary
 
543
>getx</primary
 
544
></indexterm
 
545
></term>
 
546
      <listitem
 
547
><para
 
548
><userinput
 
549
>getx</userinput
 
550
> returns the number of pixels from the left of the canvas to the current position of the turtle.</para
 
551
></listitem>
 
552
    </varlistentry>
 
553
  </variablelist>
 
554
  <variablelist>
 
555
    <anchor id="gety"/>
 
556
    <varlistentry
 
557
 
558
      <term
 
559
>gety<indexterm
 
560
><primary
 
561
>gety</primary
 
562
></indexterm
 
563
></term>
 
564
      <listitem
 
565
><para
 
566
><userinput
 
567
>gety</userinput
 
568
> returns the number of pixels from the top of the canvas to the current position of the turtle.</para
 
569
></listitem>
 
570
    </varlistentry>
 
571
  </variablelist>
497
572
</sect2>
498
573
 
499
574
<sect2 id="pen">
501
576
>De schildpad heeft een pen</title>
502
577
<para
503
578
>De schildpad heeft een pen die een lijn tekent als de schildpad beweegt. Er zijn een aantal commando's die de pen bedienen. In deze sectie leggen we deze commando's uit.</para>
504
 
<sect3 id="penup">
505
 
  <title
506
 
>penop (po)</title>
507
579
  <variablelist>
 
580
    <anchor id="penup"/>
508
581
    <varlistentry
509
582
510
583
      <term
511
 
>penop</term>
 
584
>penup (pu)<indexterm
 
585
><primary
 
586
>penup (pu)</primary
 
587
></indexterm
 
588
></term>
512
589
      <listitem
513
590
><para
514
591
><screen
515
 
>penop</screen>
 
592
>penup</screen>
516
593
<userinput
517
594
>penop</userinput
518
595
> tilt de pen van het canvas. Als de pen <quote
527
604
></listitem>
528
605
    </varlistentry>
529
606
  </variablelist>
530
 
</sect3>
531
 
<sect3 id="pendown">
532
 
  <title
533
 
>penneer (pn)</title>
534
607
  <variablelist>
 
608
    <anchor id="pendown"/>
535
609
    <varlistentry
536
610
537
611
      <term
538
 
>penneer</term>
 
612
>pendown (pd)<indexterm
 
613
><primary
 
614
>pendown (pd)</primary
 
615
></indexterm
 
616
></term>
539
617
      <listitem
540
618
><para
541
619
><screen
542
 
>penneer</screen>
 
620
>pendown</screen>
543
621
<userinput
544
622
>penneer</userinput
545
623
> zet de pen op het canvas. Als de pen op het canvas <quote
554
632
></listitem>
555
633
    </varlistentry>
556
634
  </variablelist>
557
 
</sect3>
558
 
<sect3 id="setpenwidth">
559
 
  <title
560
 
>pendikte (pd)</title>
561
635
  <variablelist>
 
636
    <anchor id="setpenwidth"/>
562
637
    <varlistentry
563
638
564
639
      <term
565
 
>pendikte</term>
 
640
>penwidth (pw)<indexterm
 
641
><primary
 
642
>penwidth (pw)</primary
 
643
></indexterm
 
644
></term>
566
645
      <listitem
567
646
><para
568
647
><screen
579
658
></listitem>
580
659
    </varlistentry>
581
660
  </variablelist>
582
 
</sect3>
583
 
<sect3 id="setfgcolor">
584
 
  <title
585
 
>penkleur (pk)</title>
586
661
  <variablelist>
 
662
    <anchor id="setfgcolor"/>
587
663
    <varlistentry
588
664
589
665
      <term
590
 
>penkleur</term>
 
666
>pencolor (pc)<indexterm
 
667
><primary
 
668
>pencolor (pc)</primary
 
669
></indexterm
 
670
></term>
591
671
      <listitem
592
672
><para
593
673
><screen
606
686
></listitem>
607
687
    </varlistentry>
608
688
  </variablelist>
609
 
</sect3>
610
689
</sect2>
611
690
 
612
 
<!--<sect2 id="canvas">
 
691
<sect2 id="canvas">
613
692
<title
614
693
>Commands to control the canvas</title>
615
694
<para
616
695
>There are several commands to control the canvas.</para>
617
 
<sect3 id="resizecanvas">
618
 
  <title
619
 
>canvassize (cs)</title>
620
696
  <variablelist>
 
697
    <anchor id="resizecanvas"/>
621
698
    <varlistentry>
622
699
      <term
623
 
>canvassize</term>
 
700
>canvassize (cs)<indexterm
 
701
><primary
 
702
>canvassize (cs)</primary
 
703
></indexterm
 
704
></term>
624
705
      <listitem
625
706
><para
626
707
><screen
627
708
>canvassize X,Y</screen>
628
 
      With the <userinput
 
709
With the <userinput
629
710
>canvassize</userinput
630
711
> command you can set the size of the canvas. It takes X and Y as input, where X is the new canvas width in <glossterm linkend="pixels"
631
712
>pixels</glossterm
639
720
></listitem>
640
721
    </varlistentry>
641
722
  </variablelist>
642
 
</sect3>
643
 
<sect3 id="setbgcolor">
644
 
  <title
645
 
>canvascolor (cc)</title>
646
723
  <variablelist>
 
724
    <anchor id="setbgcolor"/>
647
725
    <varlistentry
648
726
649
727
      <term
650
 
>canvascolor</term>
 
728
>canvascolor (cc)<indexterm
 
729
><primary
 
730
>canvascolor (cc)</primary
 
731
></indexterm
 
732
></term>
651
733
      <listitem
652
734
><para
653
735
><screen
654
736
>canvascolor R,G,B</screen>
655
 
      <userinput
 
737
<userinput
656
738
>canvascolor</userinput
657
739
> set the color of the canvas. <userinput
658
740
>canvascolor</userinput
666
748
></listitem>
667
749
    </varlistentry>
668
750
  </variablelist>
669
 
</sect3
670
 
> -->
671
751
<!-- <sect3 id="wrapon">
672
752
  <title
673
753
>wrapon</title>
719
799
></listitem>
720
800
    </varlistentry>
721
801
  </variablelist>
722
 
</sect3>
723
 
</sect2
724
 
> -->
 
802
</sect3
 
803
>  -->
 
804
</sect2>
725
805
 
726
806
<sect2 id="clean">
727
807
<title
728
808
>Commando's om schoon te maken</title>
729
809
<para
730
810
>Er zijn twee commando's waarmee je het canvas kunt schoonmaken nadat je er een bende van hebt gemaakt.</para>
731
 
<sect3 id="clear">
732
 
  <title
733
 
>schoon</title>
734
811
  <variablelist>
 
812
    <anchor id="clear"/>
735
813
    <varlistentry
736
814
737
815
      <term
738
 
>schoon</term>
 
816
>clear (ccl)<indexterm
 
817
><primary
 
818
>clear (ccl)</primary
 
819
></indexterm
 
820
></term>
739
821
      <listitem
740
822
><para
741
823
><screen
742
 
>schoon</screen>
 
824
>clear</screen>
743
825
Met <userinput
744
826
>schoon</userinput
745
827
> kun je alle tekeningen op het canvas wissen. De rest blijft staan, de positie en de hoek van de schildpad, de kleur van het canvas, de zichtbaarheid van de schildpad en de grootte van het canvas blijven zoals ze waren.</para
746
828
></listitem>
747
829
    </varlistentry>
748
830
  </variablelist>
749
 
</sect3>
750
 
<sect3 id="reset">
751
 
  <title
752
 
>alsnieuw</title>
753
831
  <variablelist>
 
832
    <anchor id="reset"/>
754
833
    <varlistentry
755
834
756
835
      <term
757
 
>alsnieuw</term>
 
836
>alsnieuw<indexterm
 
837
><primary
 
838
>reset</primary
 
839
></indexterm
 
840
></term>
758
841
      <listitem
759
842
><para
760
843
><screen
761
844
>alsnieuw</screen>
762
845
<userinput
763
 
>alsnieuw</userinput
764
 
> maakt nog meer schoon dan het commando <userinput
765
 
>schoon</userinput
766
 
>. Na het commando <userinput
767
 
>alsnieuw</userinput
768
 
> is alles zoals het was toen je &kturtle; net had opgestart. De schildpad wordt in het midden van het scherm gezet, de canvaskleur is wit en de schildpad tekent een zwarte lijn op het canvas.</para
 
846
>reset</userinput
 
847
> cleans much more thoroughly than the <userinput
 
848
>clear</userinput
 
849
> command. After a <userinput
 
850
>reset</userinput
 
851
> command everything is like is was when you had just started &kturtle;. The turtle is positioned at the middle of the screen, the canvas color is white, the turtle draws a black line on the canvas and the canvassize is set to 400 x 400 pixels.</para
769
852
></listitem>
770
853
    </varlistentry>
771
854
  </variablelist>
772
 
</sect3>
773
855
</sect2>
774
856
 
775
857
<sect2 id="sprites">
786
868
>Hierna volgt een volledig overzicht van alle commando's die je kunt gebruiken bij sprites.</para>
787
869
<para
788
870
>[De huidige versie van &kturtle; heeft alleen een schildpad als sprite. Andere sprites zijn er dus niet. In toekomstige versies van het programma zul je de schildpad kunnen veranderen in je eigen ontwerp]</para>
789
 
<sect3 id="spriteshow">
790
 
  <title
791
 
>toon</title>
792
 
  <variablelist>
793
 
    <varlistentry
794
 
795
 
      <term
796
 
>toon (ts)</term>
797
 
      <listitem
798
 
><para
799
 
><screen
800
 
>toon</screen>
801
 
<userinput
802
 
>toon</userinput
803
 
> maakt de schilpad weer zichtbaar nadat hij is verborgen. <userinput
804
 
>toon</userinput
805
 
> kun je afkorten met <userinput
806
 
>ts</userinput
807
 
>.</para
808
 
></listitem>
809
 
    </varlistentry>
810
 
  </variablelist>
811
 
</sect3>
812
 
<sect3 id="spritehide">
813
 
  <title
814
 
>verberg (vs)</title>
815
 
  <variablelist>
816
 
    <varlistentry
817
 
818
 
      <term
819
 
>verberg</term>
820
 
      <listitem
821
 
><para
822
 
><screen
823
 
>verberg</screen>
824
 
<userinput
825
 
>verberg</userinput
826
 
> verbergt de schildpad. Dit is handig als je de schildpad niet in je tekening wilt zien. <userinput
827
 
>verberg</userinput
828
 
> kun je afkorten met <userinput
829
 
>vs</userinput
830
 
>.</para
831
 
></listitem>
832
 
    </varlistentry>
833
 
  </variablelist>
834
 
</sect3>
 
871
  <variablelist>
 
872
    <anchor id="spriteshow"/>
 
873
    <varlistentry
 
874
 
875
      <term
 
876
>spriteshow (ss)<indexterm
 
877
><primary
 
878
>spriteshow (ss)</primary
 
879
></indexterm
 
880
></term>
 
881
      <listitem
 
882
><para
 
883
><screen
 
884
>spriteshow</screen>
 
885
<userinput
 
886
>spriteshow</userinput
 
887
> makes the turtle visible again after it has been hidden. <userinput
 
888
>spriteshow</userinput
 
889
> can be abbreviated to <userinput
 
890
>ss</userinput
 
891
>.</para
 
892
></listitem>
 
893
    </varlistentry>
 
894
  </variablelist>
 
895
  <variablelist>
 
896
    <anchor id="spritehide"/>
 
897
    <varlistentry
 
898
 
899
      <term
 
900
>spritehide (sh)<indexterm
 
901
><primary
 
902
>spritehide (sh)</primary
 
903
></indexterm
 
904
></term>
 
905
      <listitem
 
906
><para
 
907
><screen
 
908
>spritehide</screen>
 
909
<userinput
 
910
>spritehide</userinput
 
911
> hides the turtle. This can be used if the turtle does not fit in your drawing. <userinput
 
912
>spritehide</userinput
 
913
> can be abbreviated to <userinput
 
914
>sh</userinput
 
915
>.</para
 
916
></listitem>
 
917
    </varlistentry>
 
918
  </variablelist>
835
919
</sect2>
836
920
 
837
921
<sect2 id="writing">
838
922
<title
839
 
>Kan de schildpad schrijven?</title>
 
923
>Can the turtle write?</title>
840
924
<para
841
925
>Het antwoord is: <quote
842
926
>ja</quote
843
927
>. De schildpad kan schrijven. Hij schrijft zo'n beetje alles wat je hem opdraagt.</para>
844
 
<sect3 id="print">
845
 
  <title
846
 
>schrijf</title>
847
928
  <variablelist>
 
929
    <anchor id="print"/>
848
930
    <varlistentry
849
931
850
932
      <term
851
 
>schrijf</term>
 
933
>schrijf<indexterm
 
934
><primary
 
935
>print</primary
 
936
></indexterm
 
937
></term>
852
938
      <listitem
853
939
><para
854
940
><screen
870
956
></listitem>
871
957
    </varlistentry>
872
958
  </variablelist>
873
 
</sect3>
874
 
<sect3 id="fontsize">
875
 
  <title
876
 
>lettermaat</title>
877
959
  <variablelist>
 
960
    <anchor id="fontsize"/>
878
961
    <varlistentry
879
962
880
963
      <term
881
 
>lettermaat</term>
 
964
>lettermaat<indexterm
 
965
><primary
 
966
>fontsize</primary
 
967
></indexterm
 
968
></term>
882
969
      <listitem
883
970
><para
884
971
><screen
895
982
></listitem>
896
983
    </varlistentry>
897
984
  </variablelist>
898
 
</sect3>
899
985
</sect2>
900
986
 
901
987
<sect2 id="random">
909
995
    <varlistentry
910
996
911
997
      <term
912
 
>gok</term>
 
998
>random (rnd)<indexterm
 
999
><primary
 
1000
>random (rnd)</primary
 
1001
></indexterm
 
1002
></term>
913
1003
      <listitem
914
1004
><para
915
1005
><screen
916
1006
>gok X,Y</screen>
917
1007
<userinput
918
 
>gok</userinput
919
 
> is een commando dat invoer vraagt en uitvoer geeft. Als invoer vraagt het commando twee cijfers, het eerste cijfer (X) zet de minimum uitvoer, en het tweede (Y) zet de maximum. De uitvoer is een willekeurig gekozen getal dat gelijk is aan of groter dan het minimum en gelijk aan of kleiner dan het maximum. Hier is een klein voorbeeld:<screen>
920
 
herhaal 500 [
921
 
 $x = gok 1,20
922
 
 vooruit $x
923
 
 draailinks 10 - $x
924
 
]
 
1008
>random</userinput
 
1009
> is a command that takes input and gives output. As input are required two numbers, the first (X) sets the minimum output, the second (Y) sets the maximum. The output is a randomly chosen number that is equal or greater than the minimum and equal or smaller than the maximum. Here a small example: <screen>
 
1010
repeat 500 {
 
1011
  $x = random 1,20
 
1012
  forward $x
 
1013
  turnleft 10 - $x
 
1014
}
925
1015
</screen
926
 
> Met het commando <userinput
927
 
>gok</userinput
928
 
> kun je wat chaos aan je programma toevoegen.</para
 
1016
> Using the <userinput
 
1017
>random</userinput
 
1018
> command you can add a bit of chaos to your program.</para
929
1019
></listitem>
930
1020
    </varlistentry>
931
1021
  </variablelist>
935
1025
<title
936
1026
>Invoer en terugkoppeling met behulp van dialogen</title>
937
1027
<para
938
 
>Een dialoog is een klein venstertje waarmee enige terugkoppeling wordt verkregen of waarin om enige invoer wordt gevraagd aan de gebruiker. &kturtle; kent twee opdrachten voor een dialoog, namelijk <userinput
939
 
>bericht</userinput
940
 
> en <userinput
941
 
>invoervenster</userinput
 
1028
>A dialog is a small pop-up window that provides some feedback or asks for some input. &kturtle; has two commands for dialogs, namely: <userinput
 
1029
>message</userinput
 
1030
> and <userinput
 
1031
>ask</userinput
942
1032
></para>
943
 
<sect3 id="message">
944
 
  <title
945
 
>bericht</title>
946
1033
  <variablelist>
 
1034
    <anchor id="message"/>
947
1035
    <varlistentry
948
1036
949
1037
      <term
950
 
>bericht</term>
 
1038
>bericht<indexterm
 
1039
><primary
 
1040
>message</primary
 
1041
></indexterm
 
1042
></term>
951
1043
      <listitem
952
1044
><para
953
1045
><screen
965
1057
></listitem>
966
1058
    </varlistentry>
967
1059
  </variablelist>
968
 
</sect3>
969
 
<sect3 id="ask">
970
 
  <title
971
 
>vraag</title>
972
1060
  <variablelist>
 
1061
    <anchor id="ask"/>
973
1062
    <varlistentry
974
1063
975
1064
      <term
976
 
>vraag</term>
 
1065
>vraag<indexterm
 
1066
><primary
 
1067
>ask</primary
 
1068
></indexterm
 
1069
></term>
977
1070
      <listitem
978
1071
><para
979
1072
><screen
1001
1094
></listitem>
1002
1095
    </varlistentry>
1003
1096
  </variablelist>
1004
 
</sect3>
1005
1097
</sect2>
1006
1098
 
1007
1099
</sect1>
1021
1113
>-teken dat ervoor wordt geplaatst.</para>
1022
1114
 
1023
1115
<para
1024
 
>Plaatshouders die niet worden gebruikt zijn leeg. Een voorbeeld: <screen>
1025
 
schrijf $N
1026
 
</screen>
1027
 
 Er wordt niets op het canvas geschreven. Als we proberen met lege plaatshouders te <link linkend="math"
1028
 
>rekenen</link
1029
 
> krijgen we foutmeldingen. </para>
 
1116
>Containers that are not used contain nothing. An example: <screen>
 
1117
print $N
 
1118
</screen
 
1119
> This will print nothing and you get an error message. </para>
1030
1120
 
1031
1121
<sect2 id="variables">
1032
1122
<title
1093
1183
>tekenreeksen</link
1094
1184
>.</para>
1095
1185
<para
1096
 
>Ook tekenreeksen kunnen worden opgeslagen in <link linkend="containers"
1097
 
>plaatshouders</link
1098
 
>, net zoals <link linkend="number"
1099
 
>getallen</link
1100
 
>. Tekenreeksen lijken veel op variabelen. Het grootste verschil met getallen is dat je met tekenreeksen niet kunt <link linkend="math"
1101
 
>rekenen</link
1102
 
>. Een voorbeeld van het gebruik van tekenreeksen: <screen>
1103
 
$x = "Hallo "
1104
 
$naam = vraag "Voer je naam in..."
1105
 
schrijf $x + $naam + ", hoe gaat het met je?"
 
1186
>Strings can also be stored in <link linkend="containers"
 
1187
>containers</link
 
1188
> just like <link linkend="number"
 
1189
>numbers</link
 
1190
> Strings are a lot like variables. The biggest difference is that they contain text in stead of numbers. For this reason strings cannot be used in <link linkend="math"
 
1191
>mathematical calculations</link
 
1192
> and <link linkend="questions"
 
1193
>questions</link
 
1194
>. An example of the use of strings: <screen>
 
1195
$x = "Hello "
 
1196
$name = ask "Please enter your name..."
 
1197
print $x + $name + ", how are you?"
1106
1198
</screen
1107
 
> Op de eerste regel wordt <userinput
 
1199
> On the first line the string <userinput
1108
1200
>x</userinput
1109
 
> gesteld op <quote
1110
 
>Hallo </quote
1111
 
>. Op de tweede regel wordt de tekenreeks <userinput
1112
 
>naam</userinput
1113
 
> gesteld op de uitvoer van de opdracht <userinput
1114
 
>vraag</userinput
1115
 
>. Op de derde regel schrijft het programma een samenstelling van de drie tekenreeksen op het canvas.</para>
 
1201
> is set to <quote
 
1202
>Hello </quote
 
1203
>. On the second line the string <userinput
 
1204
>name</userinput
 
1205
> is set to the output of the <userinput
 
1206
>ask</userinput
 
1207
> command. On the third line the program prints a composition of three strings on the canvas.</para>
1116
1208
<para
1117
1209
>Dit programma vraagt je je naam in te voeren. Als je bijvoorbeeld de naam <quote
1118
1210
>Paul</quote
1126
1218
<title
1127
1219
>Kan de schildpad rekenen?</title>
1128
1220
<para
1129
 
>Ja, &kturtle; kan voor jou rekenen, namelijk optellen (+), aftrekken (-), vermenigvuldigen (*) en delen (/). Dit is een voorbeeld waarin dit alles wordt gebruikt: <screen>
 
1221
>Yes, &kturtle; will do your math. You can add (+), subtract (-), multiply (*), and divide (/). Here is an example in which we use all of them: <screen>
1130
1222
$a = 20 - 5
1131
1223
$b = 15 * 2
1132
1224
$c = 30 / 30
1133
1225
$d = 1 + 1
1134
 
schrijf "a: "+$a+", b: "+$b+", c: "+$c+", d: "+$d 
 
1226
print "a: "+$a+", b: "+$b+", c: "+$c+", d: "+$d 
1135
1227
</screen
1136
 
> Weet je welke waarden a, b, c, en d hebben? Merk in het voorbeeld het gebruik op van het <link linkend="assignment"
1137
 
>toewijs</link
1138
 
>-symbool <screen
1139
 
>=</screen
 
1228
> Do you know what value a, b, c and d have? Please note the use of the <link linkend="assignment"
 
1229
>assignment</link
 
1230
> symbol <userinput
 
1231
>=</userinput
1140
1232
>.</para>
1141
1233
<para
1142
1234
>Als je een eenvoudige rekensom wilt laten doen, dan kan dat bijvoorbeeld zo: <screen
1148
1240
schrijf ( ( 20 - 5 ) * 2 / 30 ) + 1
1149
1241
</screen
1150
1242
> Het gedeelte tussen de binnenste haakjes zal als eerste worden uitgerekend. In dit voorbeeld wordt 20 - 5 berekend, dan wordt de uitkomst vermenigvuldigd met 2, en daarna wordt er gedeeld door 30. Tot slot wordt er 1 bij opgeteld (het antwoord is 2).</para>
 
1243
<para
 
1244
>&kturtle; has advanced mathematical features. It knows the number <userinput
 
1245
>pi</userinput
 
1246
> and trigonometrical functions like <userinput
 
1247
>sin</userinput
 
1248
>, <userinput
 
1249
>cos</userinput
 
1250
>, <userinput
 
1251
>tan</userinput
 
1252
>, <userinput
 
1253
>arcsin</userinput
 
1254
>, <userinput
 
1255
>arccos</userinput
 
1256
>, <userinput
 
1257
>arctan</userinput
 
1258
> and the functions <userinput
 
1259
>sqrt</userinput
 
1260
> and <userinput
 
1261
>exp</userinput
 
1262
>. <indexterm
 
1263
><primary
 
1264
>pi</primary
 
1265
></indexterm>
 
1266
<indexterm
 
1267
><primary
 
1268
>sin, cos, tan</primary
 
1269
></indexterm>
 
1270
<indexterm
 
1271
><primary
 
1272
>arcsin, arccos, arctan</primary
 
1273
></indexterm>
 
1274
<indexterm
 
1275
><primary
 
1276
>sqrt, exp</primary
 
1277
></indexterm>
 
1278
</para>
 
1279
 
 
1280
<sect2 id="round">
 
1281
<title
 
1282
>Let the turtle round your numbers</title>
 
1283
<para
 
1284
>If you need integers in calculations, use this function.</para>
 
1285
  <variablelist>
 
1286
    <varlistentry>
 
1287
      <term
 
1288
>round<indexterm
 
1289
><primary
 
1290
>round</primary
 
1291
></indexterm
 
1292
></term>
 
1293
      <listitem
 
1294
><para
 
1295
><screen
 
1296
>round(x)</screen>
 
1297
<userinput
 
1298
>round</userinput
 
1299
> the given number to the nearest integer. <screen>
 
1300
print round(10.8)
 
1301
forward 20
 
1302
print round(10.3)
 
1303
forward 20
 
1304
</screen
 
1305
> With this code the turtle will print the numbers 11 and 10.</para
 
1306
></listitem>
 
1307
    </varlistentry>
 
1308
  </variablelist>
 
1309
</sect2>
1151
1310
</sect1>
1152
1311
 
1153
1312
<sect1 id="questions">
1302
1461
<title
1303
1462
>Vragenlijm</title>
1304
1463
<para
1305
 
>Vragen kunnen aan elkaar geplakt worden met <quote
1306
 
>vragenlijm</quote
1307
 
>. Zo kun je van een paar kleine vragen een grote vraag maken. <screen>
 
1464
>Question glue-words enable us to glue questions into one big question. <screen>
1308
1465
$a = 1
1309
1466
$b = 5
1310
 
als ($a &lt; 5) en ($b == 5) {
1311
 
 schrijf "hallo"
 
1467
if ($a &lt; $b) and ($b == 5) {
 
1468
  print "hello"
1312
1469
}
1313
1470
</screen
1314
 
> In dit voorbeeld is het lijmwoord <userinput
1315
 
>en</userinput
1316
 
> gebruikt om twee vragen (<userinput
 
1471
> In this example the glue-word <userinput
 
1472
>and</userinput
 
1473
> is used to glue 2 questions (<userinput
1317
1474
>a &lt; 5</userinput
1318
1475
>, <userinput
1319
 
> b == 5</userinput
1320
 
>) aan elkaar te plakken. Als een zijde van de <userinput
1321
 
>en</userinput
1322
 
> <quote
1323
 
>onwaar</quote
1324
 
> als antwoord heeft, dan zal de hele vraag <quote
1325
 
>onwaar</quote
1326
 
> zijn, omdat bij het lijmwoord <userinput
1327
 
>en</userinput
1328
 
> beide zijden <quote
1329
 
>waar</quote
1330
 
> moeten zijn om het antwoord <quote
1331
 
>waar</quote
1332
 
> te krijgen. Vergeet de haakjes om de vragen niet!</para>
 
1476
>b == 5</userinput
 
1477
>) together. If one side of the <userinput
 
1478
>and</userinput
 
1479
> would answer <quote
 
1480
>false</quote
 
1481
> the whole question would answer <quote
 
1482
>false</quote
 
1483
>, because with the glue-word <userinput
 
1484
>and</userinput
 
1485
> both sides need to be <quote
 
1486
>true</quote
 
1487
> in order to answer <quote
 
1488
>true</quote
 
1489
>. Please do not forget to use the brackets around the questions!</para>
1333
1490
 
1334
1491
<para
1335
1492
>Hier is een schematisch overzicht, een meer gedetailleerde uitleg volgt hieronder: <table>
1369
1526
<sect3 id="and">
1370
1527
<title
1371
1528
>en</title>
 
1529
<indexterm
 
1530
><primary
 
1531
>and</primary
 
1532
></indexterm>
1372
1533
<para
1373
1534
>Als twee vragen aan elkaar zijn gelijmd met <userinput
1374
1535
>en</userinput
1387
1548
<sect3 id="or">
1388
1549
<title
1389
1550
>of</title>
 
1551
<indexterm
 
1552
><primary
 
1553
>or</primary
 
1554
></indexterm>
1390
1555
<para
1391
1556
>Als één van de, of beide, vragen die aan elkaar zijn geplakt met <userinput
1392
1557
>of</userinput
1403
1568
<sect3 id="not">
1404
1569
<title
1405
1570
>niet</title>
 
1571
<indexterm
 
1572
><primary
 
1573
>not</primary
 
1574
></indexterm>
1406
1575
<para
1407
1576
><userinput
1408
1577
>niet</userinput
1438
1607
<para
1439
1608
>De programmastuurcommando's maken het mogelijk, &mdash;zoals de naam al zegt&mdash; het verloop van een programma te sturen.</para>
1440
1609
<para
1441
 
>Commando's die het programmaverloop sturen worden <glossterm
1442
 
>geaccentueerd </glossterm
1443
 
> met donkergroen in een vet lettertype. De accolades worden meestal samen met de programmastuurcommando's gebruikt en worden <glossterm
1444
 
>geaccentueerd</glossterm
1445
 
> met vet zwart.</para>
 
1610
>Execution controlling commands are <glossterm
 
1611
>highlighted</glossterm
 
1612
> with dark green in a bold font type. The brackets are mostly used together with execution controllers and they are <glossterm
 
1613
>highlighted</glossterm
 
1614
> with bolded black.</para>
1446
1615
 
1447
1616
<sect2 id="wait">
1448
1617
<title
1452
1621
  <variablelist>
1453
1622
    <varlistentry>
1454
1623
      <term
1455
 
>wacht</term>
 
1624
>wait<indexterm
 
1625
><primary
 
1626
>wait</primary
 
1627
></indexterm
 
1628
></term>
1456
1629
      <listitem
1457
1630
><para
1458
1631
><screen
1478
1651
  <variablelist>
1479
1652
    <varlistentry>
1480
1653
      <term
1481
 
>als</term>
 
1654
>als<indexterm
 
1655
><primary
 
1656
>if</primary
 
1657
></indexterm
 
1658
></term>
1482
1659
      <listitem
1483
1660
><para
1484
1661
><screen
1517
1694
  </variablelist>
1518
1695
</sect2>
1519
1696
 
1520
 
<sect2 id="while">
1521
 
<title
1522
 
>De lus "terwijl"</title>
1523
 
  <variablelist>
1524
 
    <varlistentry>
1525
 
      <term
1526
 
>terwijl</term>
1527
 
      <listitem
1528
 
><para
1529
 
><screen
1530
 
>terwijl <link linkend="questions"
1531
 
>vraag</link
1532
 
> { ... }</screen>
1533
 
Het programmastuurcommando <userinput
1534
 
>terwijl</userinput
1535
 
> lijkt veel op <link linkend="if"
1536
 
>als<userinput
1537
 
></userinput
1538
 
></link
1539
 
>. Het verschil is dat <userinput
1540
 
>terwijl</userinput
1541
 
> de programmacode tussen de accolades blijft herhalen totdat het antwoord op de <link linkend="questions"
1542
 
>vraag</link
1543
 
> <quote
1544
 
>onwaar</quote
1545
 
> wordt. <screen>
1546
 
$x = 1
1547
 
terwijl $x &lt; 5 {
1548
 
  vooruit 10
1549
 
  wacht 1
1550
 
  $x = $x + 1
1551
 
}
1552
 
</screen
1553
 
> Op de eerste regel krijgt <userinput
1554
 
>x</userinput
1555
 
> de waarde 1. Op de tweede regel wordt de <link linkend="questions"
1556
 
>vraag</link
1557
 
> <userinput
1558
 
>x &lt; 5</userinput
1559
 
> gesteld. Omdat het antwoord op deze vraag <quote
1560
 
>waar</quote
1561
 
> is start de programmabesturing <userinput
1562
 
>terwijl</userinput
1563
 
> het uitvoeren van de code tussen de accolades totdat het antwoord op de <link linkend="questions"
1564
 
>vraag</link
1565
 
> <quote
1566
 
>onwaar</quote
1567
 
> is geworden. In dit voorbeeld wordt de code tussen de accolades 4 keer uitgevoerd, omdat telkens als de vijfde regel wordt uitgevoerd de waarde <userinput
1568
 
>x</userinput
1569
 
> met 1 wordt vermeerderd.</para
1570
 
></listitem>
1571
 
    </varlistentry>
1572
 
  </variablelist>
1573
 
</sect2>
1574
 
 
1575
1697
<sect2 id="else">
1576
1698
<title
1577
1699
>Als niet, of in andere woorden: "anders"</title>
1578
1700
  <variablelist>
1579
1701
    <varlistentry>
1580
1702
      <term
1581
 
>anders</term>
 
1703
>else<indexterm
 
1704
><primary
 
1705
>else</primary
 
1706
></indexterm
 
1707
></term>
1582
1708
      <listitem
1583
1709
><para
1584
1710
><screen
1619
1745
  </variablelist>
1620
1746
</sect2>
1621
1747
 
 
1748
<sect2 id="while">
 
1749
<title
 
1750
>De lus "terwijl"</title>
 
1751
  <variablelist>
 
1752
    <varlistentry>
 
1753
      <term
 
1754
>while<indexterm
 
1755
><primary
 
1756
>while</primary
 
1757
></indexterm
 
1758
></term>
 
1759
      <listitem
 
1760
><para
 
1761
><screen
 
1762
>terwijl <link linkend="questions"
 
1763
>vraag</link
 
1764
> { ... }</screen>
 
1765
The execution controller <userinput
 
1766
>while</userinput
 
1767
> is a lot like <link linkend="if"
 
1768
><userinput
 
1769
>if</userinput
 
1770
></link
 
1771
>. The difference is that <userinput
 
1772
>while</userinput
 
1773
> keeps repeating (looping) the code between the brackets until the answer to the <link linkend="questions"
 
1774
>question</link
 
1775
> is <quote
 
1776
>false</quote
 
1777
>. <screen>
 
1778
$x = 1
 
1779
while $x &lt; 5 {
 
1780
  forward 10
 
1781
  wait 1
 
1782
  $x = $x + 1
 
1783
}
 
1784
</screen
 
1785
> On the first line <userinput
 
1786
>x</userinput
 
1787
> is set to 1. On the second line the <link linkend="questions"
 
1788
>question</link
 
1789
> <userinput
 
1790
>x &lt; 5</userinput
 
1791
> is asked. Since the answer to this question is <quote
 
1792
>true</quote
 
1793
> the execution controller <userinput
 
1794
>while</userinput
 
1795
> starts executing the code between the brackets until the answer to the <link linkend="questions"
 
1796
>question</link
 
1797
> is <quote
 
1798
>false</quote
 
1799
>. In this case the code between the brackets will be executed 4 times, because every time the fifth line is executed <userinput
 
1800
>x</userinput
 
1801
> increases by 1.</para
 
1802
></listitem>
 
1803
    </varlistentry>
 
1804
  </variablelist>
 
1805
</sect2>
 
1806
 
 
1807
<sect2 id="repeat">
 
1808
<title
 
1809
>The "repeat" loop</title>
 
1810
  <variablelist>
 
1811
    <varlistentry>
 
1812
      <term
 
1813
>repeat<indexterm
 
1814
><primary
 
1815
>repeat</primary
 
1816
></indexterm
 
1817
></term>
 
1818
      <listitem
 
1819
><para
 
1820
><screen
 
1821
>repeat number { ... }</screen>
 
1822
The execution controller <userinput
 
1823
>repeat</userinput
 
1824
> is a lot like <link linkend="while"
 
1825
><userinput
 
1826
>while</userinput
 
1827
></link
 
1828
>. The difference is that <userinput
 
1829
>repeat</userinput
 
1830
> keeps repeating (looping) the code between the brackets for the given number.</para
 
1831
></listitem>
 
1832
    </varlistentry>
 
1833
  </variablelist>
 
1834
</sect2>
 
1835
 
1622
1836
<sect2 id="for">
1623
1837
<title
1624
1838
>De lus "voor", een tellende lus</title>
1625
1839
  <variablelist>
1626
1840
    <varlistentry>
1627
1841
      <term
1628
 
>voor</term>
 
1842
>voor<indexterm
 
1843
><primary
 
1844
>for</primary
 
1845
></indexterm
 
1846
><indexterm
 
1847
><primary
 
1848
>step</primary
 
1849
></indexterm
 
1850
></term>
1629
1851
      <listitem
1630
1852
><para
1631
1853
><screen
1632
 
>voor <userinput
1633
 
>startpunt</userinput
1634
 
> tot <userinput
1635
 
>eindpunt</userinput
 
1854
>for <userinput
 
1855
>start point</userinput
 
1856
> to <userinput
 
1857
>end point</userinput
1636
1858
> { ... }</screen>
1637
1859
De lus <userinput
1638
1860
>voor</userinput
1650
1872
>x</userinput
1651
1873
> de waarde 10 heeft bereikt. De code tussen de accolades schrijft de waarde van <userinput
1652
1874
>x</userinput
1653
 
> vermenigvuldigd met 7. Nadat deze commando's zijn uitgevoerd zie je de tafel van 7 op het canvas staan.</para
1654
 
></listitem>
1655
 
    </varlistentry>
1656
 
  </variablelist>
1657
 
</sect2>
1658
 
 
 
1875
> vermenigvuldigd met 7. Nadat deze commando's zijn uitgevoerd zie je de tafel van 7 op het canvas staan. </para>
 
1876
     <para
 
1877
>The default step size of a loop is 1, you can use an other value with <screen
 
1878
>for <userinput
 
1879
>start point</userinput
 
1880
> to <userinput
 
1881
>end point</userinput
 
1882
> step <userinput
 
1883
>step size</userinput
 
1884
> { ... }</screen
 
1885
></para
 
1886
></listitem>
 
1887
    </varlistentry>
 
1888
  </variablelist>
 
1889
</sect2>
 
1890
 
 
1891
<sect2 id="break">
 
1892
<title
 
1893
>Leave a loop</title>
 
1894
  <variablelist>
 
1895
    <varlistentry>
 
1896
      <term
 
1897
>break<indexterm
 
1898
><primary
 
1899
>break</primary
 
1900
></indexterm
 
1901
></term>
 
1902
      <listitem
 
1903
><para
 
1904
><screen
 
1905
>break</screen>
 
1906
Terminates the current loop immediately and transfers control to the statement immediately following that loop</para
 
1907
></listitem>
 
1908
    </varlistentry>
 
1909
  </variablelist>
 
1910
</sect2>
 
1911
 
 
1912
<sect2 id="exit">
 
1913
<title
 
1914
>Stop the turtle</title>
 
1915
  <variablelist>
 
1916
    <varlistentry>
 
1917
      <term
 
1918
>exit<indexterm
 
1919
><primary
 
1920
>exit</primary
 
1921
></indexterm
 
1922
></term>
 
1923
      <listitem
 
1924
><para
 
1925
><screen
 
1926
>exit</screen>
 
1927
Finishes the execution of the code.</para
 
1928
></listitem>
 
1929
    </varlistentry>
 
1930
  </variablelist>
 
1931
</sect2>
1659
1932
</sect1>
1660
1933
 
1661
1934
 
1666
1939
></title>
1667
1940
<para
1668
1941
><userinput
1669
 
>leer</userinput
1670
 
> is een nogal apart commando, omdat die kan worden gebruikt om je eigen commando's te maken. Het commando dat je maakt kan om <glossterm linkend="input-output"
1671
 
>invoer</glossterm
1672
 
> vragen en <glossterm linkend="input-output"
1673
 
>uitvoer</glossterm
1674
 
> geven. Laten we eens kijken hoe je een nieuw commando kunt maken: <screen>
1675
 
leer cirkel $x {
1676
 
 herhaal 36 {
1677
 
   vooruit $x
1678
 
   draailinks 10
1679
 
 }
 
1942
>learn</userinput
 
1943
><indexterm
 
1944
><primary
 
1945
>learn</primary
 
1946
></indexterm
 
1947
> is a very special command, because it is used to create your own commands. The command you create can take <glossterm linkend="input-output"
 
1948
>input</glossterm
 
1949
> and return <glossterm linkend="input-output"
 
1950
>output</glossterm
 
1951
>. Let us take a look at how a new command is created: <screen>
 
1952
learn circle $x {
 
1953
  repeat 36 {
 
1954
    forward $x
 
1955
    turnleft 10
 
1956
  }
1680
1957
}
1681
1958
</screen
1682
 
> Het nieuwe commando heet <userinput
1683
 
>cirkel</userinput
 
1959
> The new command is called <userinput
 
1960
>circle</userinput
1684
1961
>. <userinput
1685
 
>cirkel</userinput
1686
 
> vraagt om een <glossterm linkend="input-output"
1687
 
>invoer</glossterm
1688
 
>, een getal, om de grootte van de cirkel te bepalen. <userinput
1689
 
>cirkel</userinput
1690
 
> geeft geen <glossterm linkend="input-output"
1691
 
>uitvoer</glossterm
1692
 
>. Het commando <userinput
1693
 
>cirkel</userinput
1694
 
> kan nu worden gebruikt als een normaal commando in de rest van de programmacode. Hier een voorbeeld: <screen
1695
 
>leer cirkel $x {
1696
 
  herhaal 36 { 
1697
 
    vooruit $x 
1698
 
    draailinks 10 
1699
 
  } 
1700
 
1701
 
 
1702
 
ganaar 30,30 
1703
 
cirkel 20
1704
 
 
1705
 
ganaar 40,40 
1706
 
cirkel 50  
1707
 
</screen>
1708
 
</para>
1709
 
<para
1710
 
>In het volgende voorbeeld maken we een commando met een uitvoerwaarde. <screen>
1711
 
alsnieuw
1712
 
 
1713
 
leer vermenigvuldigMetZichzelf $n {
1714
 
  $r = $n * 1
1715
 
 $r = $n * $n
1716
 
  geefdoor $r
1717
 
]
1718
 
$i = vraag "Voer een getal in en klik op OK"
1719
 
schrijf $i + " vermenigvuldigd met zichzelf is " + vermenigvuldigMetZichzelf  $i
1720
 
</screen
1721
 
> In dit voorbeeld wordt een nieuw commando met de naam <userinput
1722
 
>vermenigvuldigMetZichzelf</userinput
1723
 
> gemaakt. De invoer van dit commando wordt vermenigvuldigd met zichzelf en daarna doorgegeven met behulp van het commando <anchor id="return"/><userinput
1724
 
>geefdoor</userinput
1725
 
>. Het commando <userinput
1726
 
>geefdoor</userinput
1727
 
> is een manier om de waarde van een functie die je hebt gemaakt als antwoord te geven. </para>
1728
 
<para
1729
 
>Commando's kunnen meer dan een <glossterm linkend="input-output"
1730
 
>invoer</glossterm
1731
 
> nodig hebben. In het volgende voorbeeld wordt een commando gemaakt dat een rechthoek tekent. <screen
1732
 
>leer rechthoek $X, $Y {
1733
 
  vooruit $Y
1734
 
  draairechts 90
1735
 
  vooruit $X
1736
 
  draairechts 90
1737
 
  vooruit $Y
1738
 
  draairechts 90
1739
 
  vooruit $X
1740
 
  draairechts 90
1741
 
}
1742
 
</screen>
1743
 
</para>
 
1962
>circle</userinput
 
1963
> takes one <glossterm linkend="input-output"
 
1964
>input</glossterm
 
1965
>, a number, to set the size of the circle. <userinput
 
1966
>circle</userinput
 
1967
> returns no <glossterm linkend="input-output"
 
1968
>output</glossterm
 
1969
>. The <userinput
 
1970
>circle</userinput
 
1971
> command can now be used like a normal command in the rest of the code. See this example: <screen
 
1972
>learn circle $X {
 
1973
  repeat 36 {
 
1974
    forward $X 
 
1975
    turnleft 10 
 
1976
  }
 
1977
}
 
1978
 
 
1979
go 200,200 
 
1980
circle 20
 
1981
 
 
1982
go 300,200 
 
1983
circle 40  
 
1984
</screen>
 
1985
</para>
 
1986
<para
 
1987
>In the next example, a command with a return value is created. <screen>
 
1988
reset
 
1989
 
 
1990
learn multiplyBySelf $n {
 
1991
  $r = $n * $n
 
1992
  return $r
 
1993
}
 
1994
$i = ask "Please enter a number and press OK"
 
1995
print $i + " multiplied by itself is: " + multiplyBySelf $i
 
1996
</screen
 
1997
> In this example a new command called <userinput
 
1998
>multiplyBySelf</userinput
 
1999
> is created. The input of this command is multiplied by itself and then returned, using the <anchor id="return"/><userinput
 
2000
>return</userinput
 
2001
> command. The <userinput
 
2002
>return</userinput
 
2003
> command is the way to output a value from a function you have created. </para>
 
2004
<para
 
2005
>Commands can have more than one <glossterm linkend="input-output"
 
2006
>input</glossterm
 
2007
>. In the next example, a command that draws a rectangle is created. <screen>
 
2008
learn box $X, $Y {
 
2009
  forward $Y
 
2010
  turnright 90
 
2011
  forward $X
 
2012
  turnright 90
 
2013
  forward $Y
 
2014
  turnright 90
 
2015
  forward $X
 
2016
  turnright 90
 
2017
}
 
2018
</screen
 
2019
> Now you can run <userinput
 
2020
>box 50, 100</userinput
 
2021
> and the turtle will draw a rectangle on the canvas. </para>
1744
2022
  
1745
2023
</sect1>
1746
2024