Bennu Game Development

Foros en Español => General => Topic started by: JaViS on October 17, 2013, 04:42:54 PM

Title: Bug: retorno de string
Post by: JaViS on October 17, 2013, 04:42:54 PM
Buenas, quiero reportar un bug con el retorno de strings desde las funciones


retornar un string de una funcion anda bien


lo que no anda bien es retornar un string desde una funcion que retorna string, es decir, algo como lo siguiente;ç


[font=Verdana][size=10px]

function string get_nombre()
begin
    return nombre();
end



function string nombre()
begin
    return "lol";
end
[/size][/font]
Title: Re:Bug: retorno de string
Post by: SplinterGU on October 28, 2013, 04:16:54 PM

splinter@linux-dtax:~/tmp> cat string.prg
import "mod_say";

function string nombre()
begin
    return "lol";
end

begin
say(nombre());
end

splinter@linux-dtax:~/tmp> bgdc string.prg
BGDC 1.0.0 (Oct  2 2013 23:03:10)
Bennu Game Development Compiler

Copyright (c) 2006-2013 SplinterGU (Fenix/BennuGD)
Copyright (c) 2002-2006 Fenix Team (Fenix)
Copyright (c) 1999-2002 Jos� Luis Cebri�n Pag�e (Fenix)


File string.dcb compiled (36901 bytes):

  Processes                     2
  Global data                 212 bytes
  Local data                  208 bytes
  Private data                  0 bytes
  Public data                   0 bytes
  Code                         36 bytes
  System processes             58
  Globals vars                 21
  Locals vars                  27
  Private vars                  0
  Publics vars                  0
  Identifiers                 476
  Structs                       4
  Strings                      17 (144 bytes)

splinter@linux-dtax:~/tmp> bgdi string
lol
splinter@linux-dtax:~/tmp>


podrias dar mas detalles?
Title: Re:Bug: retorno de string
Post by: JaViS on October 28, 2013, 04:54:48 PM

El ejemplo que da error sería mas o menos asi:



import "mod_say";


function string nombre()
begin
    return "lol";
end



function string nombre_again()
begin
    return nombre();
end




begin
say(nombre_again());
end
Title: Re:Bug: retorno de string
Post by: SplinterGU on October 28, 2013, 06:33:07 PM

splinter@linux-dtax:~/tmp> bgdc string.prg
BGDC 1.0.0 (Oct  2 2013 23:03:10)
Bennu Game Development Compiler

Copyright (c) 2006-2013 SplinterGU (Fenix/BennuGD)
Copyright (c) 2002-2006 Fenix Team (Fenix)
Copyright (c) 1999-2002 Jos� Luis Cebri�n Pag�e (Fenix)


File string.dcb compiled (37065 bytes):

  Processes                     3
  Global data                 212 bytes
  Local data                  208 bytes
  Private data                  0 bytes
  Public data                   0 bytes
  Code                         52 bytes
  System processes             58
  Globals vars                 21
  Locals vars                  27
  Private vars                  0
  Publics vars                  0
  Identifiers                 477
  Structs                       4
  Strings                      17 (144 bytes)

splinter@linux-dtax:~/tmp> bgdi string
lol
splinter@linux-dtax:~/tmp> cat string.prg
import "mod_say";

function string nombre()
begin
    return "lol";
end

function string nombre_again()
begin
    return nombre();
end

begin
say(nombre_again());
end



a mi me funciona.

que version estas usando?
Title: Re:Bug: retorno de string
Post by: JaViS on October 28, 2013, 06:59:38 PM
Perdon, Ya encontre el problema, es cuando pones la funcion "padre" despues de la q llamas:


import "mod_say";


function string nombre_again()


begin
return nombre();
end


function string nombre()
begin
    return "lol";
end


begin
say(nombre_again());
end

[size=78%]
[/size]

Copyright (c) 2006-2012 SplinterGU (Fenix/BennuGD)
Copyright (c) 2002-2006 Fenix Team (Fenix)
Copyright (c) 1999-2002 JosÚ Luis Cebrißn Pag³e (Fenix)


File C:\Users\Javis\Documents\Game Development\test\string_rest.dcb compiled (13
538 bytes):

  Processes                     3
  Global data                 140 bytes
  Local data                   44 bytes
  Private data                  0 bytes
  Public data                   0 bytes
  Code                         60 bytes
  System processes              5
  Globals vars                  3
  Locals vars                   7
  Private vars                  0
  Publics vars                  0
  Identifiers                 186
  Structs                       1
  Strings                       5 (33 bytes)

4
Press any key to continue . . .


[/code]
Title: Re:Bug: retorno de string
Post by: SplinterGU on October 28, 2013, 07:03:46 PM
pero ahi imprimio un numero, en el post que habre el hilo, habias puesto algo como ç

por eso no te dije lo del uso antes de la compilacion de la funcion...
Title: Re:Bug: retorno de string
Post by: JaViS on October 28, 2013, 07:06:54 PM
...hum puede ser porque en mi codigo original (mucho mas largo, no daba para ponerlo aca) estaba concatenando antes de retornar y quizas eso hacia algun caracter raro.
Title: Re:Bug: retorno de string
Post by: SplinterGU on October 28, 2013, 09:20:05 PM
eso es probable.
Title: Re:Bug: retorno de string
Post by: JaViS on October 28, 2013, 09:22:26 PM
Entonces no es un bug, es que hay q poner las funciones que usas antes de donde las usas, no?
Title: Re:Bug: retorno de string
Post by: SplinterGU on October 28, 2013, 09:33:27 PM
si, o declararlas.
Title: Re:Bug: retorno de string
Post by: JaViS on October 28, 2013, 09:38:47 PM
Quote from: SplinterGU on October 28, 2013, 09:33:27 PM
si, o declararlas.


Claro, ahora entiendo. Gracias!