Skip to main content

Ref

Ref (फ़ंक्शन)​

प्रारूप​

subroutine सबरूटीन_नाम ( ref(चर),चर )
call सबरूटीन_नाम ( // ref(चर),चर// )

function फ़ंक्शन_नाम ( ref(चर),चर )
फ़ंक्शन_नाम ( ref(चर),चर )
पूर्णांक_व्यंजक लौटाता है

विवरण​

डिफ़ॉल्ट रूप से सबरूटीनों और फ़ंक्शनों को मान "मान द्वारा" (by value) दिए जाते हैं। इसका अर्थ है कि रूटीन बुलाते समय आप जो मान देते हैं वह एक ऐसे चर में कॉपी होता है जो रूटीन का है और पूरी तरह उसी का स्थानीय है।
ref() घोषणा से आप रूटीन को किसी चर या ऐरे का संदर्भ दे सकते हैं। जब रूटीन संदर्भित चर का मान बदलता है, तो बदलाव असल में रूटीन कॉल में इस्तेमाल हुए मूल चर में होता है।

उदाहरण​

dim a(10)
call assignarray(ref(a),10)
print "total="+totalarray(ref(a),10)
end

subroutine assignarray(ref(array), arraylen)
# ऐरे के तत्व सेट करें
for t = 0 to arraylen-1
array[t]= t*t
print array[t]
next t
end subroutine

function totalarray(ref(array),arraylen)
totalarray = 0
for t = 0 to arraylen-1
totalarray += array[t]
next t
end function

यह दिखाएगा:\

0
1
4
9
16
25
36
49
64
81
total=285

यह भी देखें​

Begin Case / Case / End Case, Call, Continue Do, Continue For, Continue While, Do / Until, End, Exit Do, Exit For, Exit While, For / Next, For Each / Next, Function, Global, Goto, Gosub, If Then, Pause, Ref, Rem, Return, Subroutine, While / End While

इतिहास​

0.9.9.13इस संस्करण में नया