AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Function: String params call by reference? (https://forums.alliedmods.net/showthread.php?t=6350)

Mugwump 09-28-2004 20:08

Function: String params call by reference?
 
In a function with prototype: func(blah, string[], strlen)

modifying this string[] in the function will affect the string in the calling subroutine?

-Mug

Freecode 09-28-2004 20:11

if its a global string

Mugwump 09-28-2004 20:19

Ugh, so this wont work?

Code:
func1(blah, string[], len) {    // modify string } func2(){    new string[48]    func1(blah, string, 47) }

If not how might I rewrite func1 so that it returns a string value, I tried this earlier and kept getting various string related errors...

Thanks,
Mug

Mugwump 09-29-2004 13:58

Freecode, are you sure about your statement? Case in point:

Calls to get_user_name(id, name, len) treat name as call by reference and modify the calling variable in place, whether it is global or defined locally...

Anyone have the answer to my original question, or does thre above answer it? :)

Thanks,
Mug

PM 09-29-2004 15:11

AFAIK, arrays are passed by reference, and should be modifyiable from the function. I'm not 100% sure though.

Mugwump 09-29-2004 20:37

Gotcha, thanks. :)

-Mug


All times are GMT -4. The time now is 17:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.