RETURN Wert von Functionen

Previous topic - Next topic

HeikoJ

Hallo,

ich habe folgenden Function geschrieben :

FUNCTION TextSchwierigkeit:schw
  LOCAL text$

    SELECT schw
      CASE 1
        text$ = "Hard"
      CASE 2
        text$ = "Medium"
      DEFAULT
        text$ = "Easy"
    ENDSELECT

  RETURN text$  
ENDFUNCTION

So erfolgt nun der Aufruf :

    schw$ = TextSchwierigkeit(geschwindigkeit)
    PRINT schw$  ,14*size, 10*size

Der Befehl Print gibt immer nur "0" aus. Wenn ich aber durch die Function debuge, enthält
die Variable "text$" den richtigen wert.

Warum funktioniert das nicht ???

Gruß Heiko

D2O

Function als String ($) deklarieren ;)


Code (glbasic) Select
//So erfolgt nun der Aufruf :
    schw$ = TextSchwierigkeit$(geschwindigkeit)
    PRINT schw$  ,14*size, 10*size
   
    SHOWSCREEN
   
    MOUSEWAIT



FUNCTION TextSchwierigkeit$:schw
  LOCAL text$

    SELECT schw
      CASE 1
        text$ = "Hard"
      CASE 2
        text$ = "Medium"
      DEFAULT
        text$ = "Easy"
    ENDSELECT

  RETURN text$
ENDFUNCTION
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

HeikoJ

Hallo,

danke, genau das wars.

Gruß Heiko