plusieurs argument retourné des procedures

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

plusieurs argument retourné des procedures

Post by dobro »

hello !
....----->
Last edited by dobro on Fri Jun 22, 2007 11:34 am, edited 1 time in total.
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post 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 )
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
gogo
User
User
Posts: 11
Joined: Wed Jan 31, 2007 11:18 am
Location: France

Post 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()
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post by Heathen »

Edit: Double post
Last edited by Heathen on Fri Jun 22, 2007 1:40 pm, edited 1 time in total.
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post 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
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

ho ! yes ! very nice !! :D

thanks !
Merci a vous deux !!

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

:lol: :lol:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post 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 
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post 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
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
gogo
User
User
Posts: 11
Joined: Wed Jan 31, 2007 11:18 am
Location: France

Post 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.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
gogo
User
User
Posts: 11
Joined: Wed Jan 31, 2007 11:18 am
Location: France

Post 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.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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
oh... and have a nice day.
Post Reply