Jump to content

How the ByRef acts in this scenario?


Guest
 Share

Recommended Posts

Null is not a variable, so your example has only a vague association with my comment which you quoted above. You are doing something which has not been documented, and the behaviour you are seeing is perhaps the result of some internal code which has somehow avoided the radar of detection. There's something going on and we don't know what it is.

Link to comment
Share on other sites

I think I get it -

If I pass non-variable then it allocate new memory.  otherwise it will reference to the source variable.
correct?

Which seemed odd to me is why it accepted non-variable at the first place.. so jchd said that it was a " a feature request already made".. I don't know what is the point of this feature..

Now I understand correctly the story?

Edited by Guest
Link to comment
Share on other sites

No, I referred to a recent post about optional ByRef args, see this ticket https://www.autoitscript.com/trac/autoit/ticket/3540

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Of course that's correct. Else how do you think you could "pass something" without allocating memory? C and friends use the program stack, AutoIt allocates a hidden variable (variant) for storing the "non-variable" (here I interpret that term as "a literal"). In all cases you have to store a value in a chunk of memory to pass it away.

Few programming languages rely entirely on white magic.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

The interpreter works like this (line by line):

; I am the interpreter!

SomeFunc(Null)  ; I need to call SomeFunc. First let me check that the function exist. Oh great, it does, found it in list of all functions that I created at the beginning!
                ; Ok I need to create the list of arguments for this call, the user is passing one parameter.
                ; The list of arguments will therefore have one member.
                ; Let me first create unnamed variable (because user passes literal) with value of Null. Done!
                ; Time for the list of arguments...
                ; Hm, I see that inside definition of SomeFunc the first argument is ByRef, so I'll add reference to the unnamed variable I created moment ago to the list. Dang bang... done!
                ; Calling the function now.

Func SomeFunc(ByRef $Output)
    ; I'm inside a function and I have one local variable named $Output to work with plus no global variables. This $Output is ByRef, so
    ; I won't be allocating anything.
    $Output = 1 ; The user is changing the value of $Output variable. I see that $Output is reference. Accessing the original variable... changing... Done!
    ;...
    ConsoleWrite($Output & ' (L: ' & @ScriptLineNumber & ')' & @CRLF) ; This will print 1
EndFunc

More clear?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

So to get an optional ByRef parameter, all you have to do is alter this part.

; Let me first create unnamed variable (because user passes literal) with value of Null. Done!
; Let me first create unnamed variable (because user passes nothing) with value of nothing. Done!

; Edit - I forgot to include the next line.
; Assign default value to unnamed variable. Done!

Is that right?

Edited by czardas
Link to comment
Share on other sites

@trancexx thanks for confirmation.

@czardas, no I think the number of parameters will be 0 (parameter list empty) and no unnamed variable will get created at call time. Only inside the callee will one (or more) temp variable(s) be created with its/their default value, due to the difference of the number of parameters declared and the number of arguments actually passed. And I guess that in this case their ByRef attributes will be simply ignored, since it make zero difference.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • 2 weeks later...

@GogoTraining,

Care to reconsider?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

1 hour ago, GogoTraining said:

ByRef parameters are certainly a useful concept but they are not currently available in AutoIt.

320px-Paris_Tuileries_Garden_Facepalm_st

https://www.autoitscript.com/autoit3/docs/keywords/Func.htm

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • 4 weeks later...

It's all about language specifications, not divination, preference, expectation or belief.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...