Page 1 of 1

plusieurs argument retourné des procedures

Posted: Wed Jun 20, 2007 10:00 am
by dobro
hello !
....----->

Posted: Fri Jun 22, 2007 11:33 am
by dobro
rather as in OMIKRON BASIC to make precede the variables by return of a “R” to announce to it this variable is used of parameter and variable of return!! as follows

example
in omikron BASIC to recover several value it is enough to make precede the variables by parameters by the procedure by the letter " R "

en omikron basic pour recuperer plusieurs valeur il suffit de faire preceder les variables de parametres de la procedure de la lettre" R"

comme ça :

on defini la procedure :

DEF PROC plus_court (Rcpt, Rnom)
LOCAL i,gt : rem 2 variable locales
FOR i = max(cpt,nom) to 1 STEP -1
IF frac(cpt/i)=0 AND frac(nom/i)=0 THEN gt=i:EXIT
NEXT i
cpt=cpt/gt:nom=nom/gt
RETURN

le prg qui utilise la procedure :
x=36:y=42

plus_court(x,y):REM pas besoin de metre les 'R' pour l'appel des procedures
PRINT x,y
les x=36 et y=42
deviennent apres l'appel de la procedure
x=6 et y=7 !!! :D

bien sur le nombre de paramètres retournés, correspond au nombre de paramètre précédé d'un R

(well on the number of turned over parameters, corresponds to the number of parameter preceded by one R )

Posted: Fri Jun 22, 2007 1:38 pm
by gogo
Salut dobro,

C'est pas çà que tu cherche ?

Code: Select all

Procedure p(*a.LONG,*b.LONG)

  *a\l = 10
  *b\l = 10

EndProcedure

OpenConsole()

  a = 20
  b = 30
  p(@a,@b)

  PrintN("a="+Str(a))
  PrintN("b="+Str(b))
  
  Input()
CloseConsole()

Posted: Fri Jun 22, 2007 1:39 pm
by Heathen
Edit: Double post

Posted: Fri Jun 22, 2007 1:40 pm
by Heathen
If I understood your post correctly, which was very hard to do, I think you are talking about being able to use pointers. This feature is already in purebasic using the @symbol

Code: Select all

Procedure test(x,y)
  PokeL(x,100)
  PokeL(y,200)
EndProcedure

x = 10
y = 50

test(@x,@y)
debug x
debug y

edit: looks like someone beat me to it :P

Posted: Tue Jun 26, 2007 12:51 pm
by dobro
ho ! yes ! very nice !! :D

thanks !
Merci a vous deux !!

j'y avait pas pensé !! :oops:

:lol: :lol:

Posted: Tue Jun 26, 2007 1:10 pm
by dobro
mais c'est lourding non ? ::: but it is heavy not?
exemple en purebasic ::: example in purebasic




Code: Select all

Procedure divise_par_deux(x,Y)
    x2=PeekL(x)/2
    y2=PeekL(Y)/2  
    
    PokeL(x,x2) 
    PokeL(Y,y2)
EndProcedure

CallDebugger
x = 10
Y = 50

divise_par_deux(@x,@Y)
Debug x
Debug Y

and in Omikron BASIC
Procedure divise_par_deux(Rx,RY)
x=x/2
Y=Y/2
EndProcedure

x=10
Y=20
divise_par_deux(x,Y)


----> Resultat
x=5
Y=10

si cette syntaxe existais en purebasic, quelle confort non ? ::: if this syntax existed in purebasic, which comfort not?

:D

Fred ce serai possible ou pas ? :shock:


[Reedit !]

Flype m'a donné un code qui correspond mieux !! :D
plus clair et simple :D ::: Flype gave me a code which corresponds better!! : D clearer and simple

Code: Select all

	
    Procedure divise_par_deux(*x.Long, *y.Long) 
        *x\l / 2
        *y\l / 2 
    EndProcedure
    
    CallDebugger
    
    x = 10
    Y = 50
    
    divise_par_deux(@x, @Y)
    
    Debug x
    Debug Y 

Posted: Tue Jun 26, 2007 2:19 pm
by Kaeru Gaman
if this syntax existed in purebasic, which comfort not?
it would be SHEER HORROR!

what if I wanted to use a parameter-name starting with an "R"?
Procedure Calculation( Angle, Radius )
ProcedureReturn Sin(Angle * #PI / 180) * Radius
EndProcedure
what would happen in Omikron-Basic?
1. would it produce an error, because there is no upper variable called adius?
2. would it produce an error, because the local variable Radius isn't declared?

using a simple letter for a classification is anything else but productive!

special caracters can be used for classifications,
as is the @ for the adress or the * for a pointer.

it is fine the way it is.

Posted: Tue Jun 26, 2007 3:49 pm
by dobro
Kaeru Gaman wrote: what if I wanted to use a parameter-name starting with an "R"?
Procedure Calculation( Angle, Radius )
ProcedureReturn Sin(Angle * #PI / 180) * Radius
EndProcedure

cela aurai pu etre R_ au lieu de R :::::that could have been R_ instead of R


ce qui donnerai :::what will give :
Procedure Calculation( Angle, R_Radius )
ProcedureReturn Sin(Angle * #PI / 180) * Radius
EndProcedure
il y a toujours un moyen de trouver une convention:::it is possible always to find a convention :D

using a simple letter for a classification is anything else but productive!
special caracters can be used for classifications,
as is the @ for the adress or the * for a pointer.
it is fine the way it is.

effectivement :::: indeed :D

d'ailleurs mon dernier exemple fourni par Flype le démontre:::
moreover my last example provided by Flype shows it

enfin c'etait une idée ::::finally it was an idea :D

Posted: Tue Jun 26, 2007 4:15 pm
by gogo
Sorry for the non-french speaking people 8) Go to learn a new language ... french :D

Dobro, tu dois surement vouloir une syntaxe de ce type :

Code: Select all

Sub Divise_par_2(ByRef a As Integer,ByRef b As Integer)
	a /= 2
	b /= 2 
End Sub

Dim a As Integer
Dim b As Integer

a = 20
b = 50

Divise_par_2(a,b)

Print " a = ",a
Print " b = " ,b

sleep
Cet exemple est en FreeBasic. PureBasic n'a que des passages de paramètres par valeur. Tu dois explicitement passer l'adresse d'une variable pour simuler le passage de référence. Peut-être que dans la version 5 nous aurons le passage par ref. si nous sommes suffisament nombreux à le demander .....

Mais cette modification n'est pas anodine pour le compilateur.

Posted: Tue Jun 26, 2007 4:42 pm
by Kaeru Gaman
that could have been R_ instead of R
well, an Underscore is also a legal part of a Variable name.

I can define a Variable like Master_Of_Puppets.l or anything I like.
therefor again, it is not praktiable to use chars that are legal for variables to classify anything.

> it is possible always to find a convention
sure, not usings legal chars for classifying.. ;)

> moreover my last example provided by Flype shows it
so, now that you know how to do it in PB, I think you will not need any "R_" stuff anymore... :)


> Go to learn a new language ... french
Wieviele Sprachen soll ich denn dann lernen?
Eigentlich wuerde mich eher Spanisch oder Italienisch interessieren,
und wenn ich sehr viel Zeit haette, wuerde ich mich um Japanisch bemuehen...

english is really easy enough for everybody, so it's the ideal international conversation language.

Posted: Wed Jun 27, 2007 8:36 am
by gogo
Bonjour Kaeru Gaman,

I studied German many, many years ago. And you can't imagine how much I regret to not have studied it more and better....

I agree with you on two points :

* we don't need prefixed parameters with special meaning(fred, please never change the compiler this way). I can't imagine how long it will take to verify all code written by all of us to see if all parameters in all functions do not use the special prefix :?

* English is enough in this forum (even if it's a multicultural one). I gave an answer in french to Dobro because he seems to understand it better.

PS : try to learn Japanese, it's really an amazing language and culture.

Posted: Wed Jun 27, 2007 1:01 pm
by Kaeru Gaman
I never learned french in school, thus it's a bit a problem for me.
I can understand 20%-40% of the words, because they have latin roots,
but to get the grammar it's a lot of guessing...

Yes, Japanese is fascinating.
I already know quite a lot about the culture, I even understand some of the more unfamiliar points of the japanese way of thinking...
but I only know few words, fewer grammar, and the charset is a horror... xD