English
Forum

Several Return values

 

Hubert
Binnewies
Hello together..

small trouble..
i'd me gladly a couple functions write The me the program on my derzeitigen proposition vereinfachen.
the stupid is only that I into most functions several Rückgabewerte have.

I Have The Help in XProfan through and always only seen the one with RETURN only a worth back give can.

or Have I there what overlooking?

How can I several values give back?

thanks Schonmal beforehand.

Hubert
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
09/15/06  
 




RGH
No, you have nothing overlooking: How in all others Languages too has a function extakt one Funktionsergebnis and accordingly a Return Value.

in principle there two Opportunities, these Limitierung To bypass:

1. to that a could You several values as Teilstring one Strings transfer. XProfan has, particularly ex Version 10, mighty command to that Use with Substrings. so could to that example in the procedure stand:
CompileMarkSeparation
!return str$(x%) + ";" + str$(y) + ";" + str$(z%)
>

in the aufrufenden Program sähe it then so from:
CompileMarkSeparation
!erg$ = meineFunktion()
x% = val(substr$(erg$,1,";")
y% = val(substr$(erg$,2,";")
z% = val(substr$(erg$,3,";")pre>

2. The others Possibility is the usage of/ one structure or. one Objektes, there hierbei Yes only the Zeiger on The function transfer becomes:
CompileMarkSeparation
!STRUCT TErg = x%, y%, z%
DIM Erg#, TErge>

The function would so looks:
CompileMarkSeparation
!PROC meineFunktion
Parameters E#
<...>
E#.x% = ...
E#.y% = ..
E#.z% = ..
<...>

END
a>

About return would I possible yet zurückggeben, whether The function successful was. in the aufrufenden Program sähe it then about so from:
CompileMarkSeparation
!success% = meineFunktion(Erg#)
x% = Erg#.x%
y% = Erg#.y%
z% = Erg#.z%

with the second Solution can also komplexere data elegant zurückgeliefert go. (These Solution is too in others Programmiersprachen right common.)

Greeting
Roland
 
Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4
09/15/06  
 




Hubert
Binnewies
thanks for really erschöpfende operator....

but I think I take a further Possibility...

I definiere me suitable globale variables The I in the Procedur always first vain and then with the Return Value versehe.

sooft How I The Proceduren need rewards itself the take action think I..

but again thanks... your response I will with safety later time need.

Hubert
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
09/15/06  
 



Have here another example, without jegliche globale Variable. Simuliertes byRef
CompileMarkSeparation
Struct Long = l&

Proc Test1

    parameters a1&, a2&
    Declare B#
    Dim B#, Long
    B# = a1&
    B#.l& = 50  50 in c& von Test2 schreiben
    B# = a2&
    B#.l& = 100  100 in d& von Test2 schreiben
    Dispose B#  lokale Bereichsvariable wird nicht mehr gebraucht

EndProc

Proc Test2

    Declare c&, d&
    Test1 Addr(c&), Addr(d&)
    print "Wert von c& = " + Str$(c&) + "  d& = " + Str$(d&) + " in der Proc"

EndProc

Declare c&, d&
cls
Test2
Print
Print "Globales c& = " + Str$(c&) + "  Globales d& = " + Str$(d&) + " wurden nicht verändert!"
waitkey

Proc Test2 over gives whom Pointer of c& and d& on Proc Test1, which there 50 and 100 as Return enters. How one see, no global Variables and the area becomes too same disposed

hope time, the can someone use

// Nachtrag:
Have whom code yet something extended, so one sees, the it really goes

here again without Hilfsstructur, Have I not at all dran virtual, the it in Profan too so goes:
CompileMarkSeparation
Proc Test1

    parameters a1&, a2&
    Declare B#
    Dim B#,4
    B# = a1&
    Long B#,0 = 50  50 in c& of Test2 write
    B# = a2&
    Long B#,0 = 100  100 in d& of Test2 write
    Dispose B#  local Memory-Variable becomes not More used

ENDPROC

Proc Test2

    Declare c&, d&
    Test1 Addr(c&), Addr(d&)
    print "Wert of c& = " + Str $(c&) + "  d& = " + Str $(d&) + " in the Proc"

ENDPROC

Declare c&, d&
c& = 1
d& = 1
cls
Test2
Print
Print "Globales c& = " + Str $(c&) + "  Globales d& = " + Str $(d&) + " get not changed!"
waitkey

is Perhaps verständlicher
 
09/15/06  
 



Weils so beautiful is, yet The simplest Variante (Have so unfortunately yet To little made )
CompileMarkSeparation
Proc Test1

    parameters a1&, a2&
    Long a1&,0 = 50
    Long a2&,0 = 100

EndProc

Proc Test2

    Declare c&, d&
    Test1 Addr(c&), Addr(d&)
    print "Wert von c& = " + Str$(c&) + "  d& = " + Str$(d&) + " in der Proc"

EndProc

Declare c&, d&
c& = 1
d& = 1
cls
Test2
Print
Print "Globales c& = " + Str$(c&) + "  Globales d& = " + Str$(d&) + " wurden nicht verändert!"
waitkey
 
09/15/06  
 



Ähem - You änderst still nothing moreover as the value of global variables - and the too yet umständlich.
 
09/15/06  
 



[quote:a6584bda33=iF]Ähem - You änderst still nothing moreover as the value of global variables - and the too yet umständlich. [/quote:a6584bda33]
The variables in both Proc are pub, Proc Test1 changes The variables of Test2, Gleichnamige Globale variables stay too receive. functions so though not Strings. Globale variables go not changed

I commit whom Pointer and make a profanischen Poke
 
09/15/06  
 



Ne balderdash - You deklarierst two Globale - The änderst You in Proc - More not. your code is not without Globals The You uses.

or stand I aufm Hose?
 
09/15/06  
 



[quote:869f8d550b=iF]Ne balderdash - You deklarierst two Globale - The änderst You in Proc - More not. your code is not without Globals The You uses.

or stand I aufm Hose? [/quote:869f8d550b]
by me GEHTS::
CompileMarkSeparation
Proc Test1

    parameters a1&, a2&
    Long a1&,0 = 50
    Long a2&,0 = 100

EndProc

Proc Test2

    Declare c&, d&
    Test1 Addr(c&), Addr(d&)
    print "Wert von c& = " + Str$(c&) + "  d& = " + Str$(d&)

EndProc

Test2
09/15/06  
 



alas now! clear! Have the Declare in the second Proc overlooking!

Thomas wants say, simple The Adressen the variables on a Proc transfer, and the Variableninhalte by Long Change.
 
09/15/06  
 




Hubert
Binnewies
ööööööhmmmmmm.....

and if I no numerischen values separate Strings have??

(not so bad The Solution, can I use)

Greeting Hubert
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
09/15/06  
 




Rolf
Koch
only to expansion:
since Ewigkeiten schlummert under Own Codes folgenders on of my Page
More than a Parameter a procedure zurückliefern - New (19.03.2003)

one ought to too time on of my Page look *lol*
 
09/15/06  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.153 Views

Untitledvor 0 min.
Normann Strübli02/05/23
H.Brill11/05/22
RudiB.04/25/21
Michael W.08/16/17
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie