![]() |
Function not returning a value
Hello,
I have made a pretty neat function that replaces a value from inside of a string to another value. This would have worked great, but for some reason, it's not returning the correct value. I have echoed the value before it is returned, and that value is correct, but it will not work for the return. PHP Code:
Thanks in advance for helping me :) |
you might want to check this replaceText() function by Tigairus as it is requiring less loops.
I'm not really sure about your problem though :/ |
Without spending much time trying to understand your script, it's clear that your recursion is flawed. replaceVal(temp.newstring, temp.oldval, temp.newval); may or may not return anything, but it doesn't matter because you don't return that value, so the original call to the function won't see it. In other words, if the if-statement evaluates to true, which I'm guessing it does in the first call, there will never be a return value.
The echo you are seeing is actually from the deepest function call, and the value is returned correctly, but then you don't do anything with the return value when it is passed back to the same function. My guess is that simply adding return in front of the recursive call will fix it, but I'm not in a position to test it right now. |
Learn to recurse:
PHP Code:
|
I knew my script was overkill :P. Anyway, thanks for linking Tig's script. I wasn't able to find any function to do this for me anyway.
|
I don't want to spam all the forums with my threads, so here's another question. Is it possible to get the path of the selected node in a GuiTreeViewCtrl? For example, if Hey.txt is selected and that value is inside Hello, then it would return Hello/Hey.txt.
If there is not a current way to do this, a function like getSelectedNodePath() would be excellent :D |
Quote:
The wiki suggests that the following event exists for GuiTreeViewCtrl: Quote:
|
Quote:
|
All times are GMT +2. The time now is 10:43 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.