quarta-feira, 18 de dezembro de 2013

18.04.01.11.05 Func

'const func' é uma declaração para uma função.

O nome está após : (dois-pontos)

As instruções estão após is.

 

func

 

 

 

const func boolean: flipCoin is

  return rand(FALSE, TRUE);

 

 

Retorno: boolean

Nome...: flipCoin

 

 

 

const func float: inverse (in float: x) is

  return 1/x;

 

 

Retorno: float

Nome...: inverse

 

 

 

const func string: str (in suitType: suit) is

  return [] ("clubs", "diamonds", "hearts", "spades") [succ(ord(suit))];

 

 

Retorno: string

Nome...: str

Parâmetro 1

  Tipo: suitType

  Nome: suit

Valor.: ?

 

 

 

const func string: str (in rankType: rank) is

  return [] ("two", "three", "four", "five", "six", "seven",

             "eight", "nine", "ten", "jack", "queen", "king", "ace") [succ(ord(rank))];

 

 

Nome...: str

Parâmetro 1

  Tipo: rankType

  Nome: rank

Valor.: ?

 

 

 

 

const func cardType: malloc (ref cardType: aCard) is func

  result

    var cardType: newCard is cardType.value;

  begin

    newCard := aCard;

  end func;

 

 

Retorno: cardType

Nome...: malloc

Parâmetro 1

  Tipo: cardType

  Nome: aCard

Valor.: ?

 

 

 

 

const func image: select_card is func

  result

    var image: anImage is image.value;

  local

    var integer: xPos is 0;

    var integer: yPos is 0;

    var PRIMITIVE_WINDOW: win is PRIMITIVE_WINDOW.value;

  begin

    xPos := getxpos(KEYBOARD);

    yPos := getypos(KEYBOARD);

    win := buttonWindow(KEYBOARD);

    if win in imageHash then

      anImage := imageHash[win];

      # writeln(str(anImage));

    end if;

  end func;

 

 

Retorno: image

Nome...: select_card

Valor.: ?

 

 

 

 

 

Nenhum comentário:

Postar um comentário