| 07-18-2004, 04:46 PM | #1 |
I've been looking at scripts and reading tutorials for a little while, to get a hold of the JASS language and programming in general as my previous experience is limited to some lame attempts to learn JAVA. However, now that i atleast understand some things and understand what most scripts mean i've got a question. In some posts, the return bug is mentioned and weeadar said somwhere that the biggest part of JASS's advanced functionality is based upon the existance of this bug. So, now i I'm wondering: What is the return bug, how can you exploit it and how does it work? I don't know if this question is stupid or something that's very obvious, but as i said, i do not know very much about programming or JASS and i'm a noob to it. Thanks in advance - MilkmaN |
| 07-18-2004, 06:03 PM | #2 |
The return bug allows a function to return a value of any type regardless of it's return type. Since all handle-derived types are actually pointers (please learn about these terms in some programming guide), they are integers. So basically a unit variable for example is a number pointing to the unit object. The big benefit of the return bug is, that it allows us to store handle-derived types in gamecaches (that's why weaaddar is in favor of it). Handle variables (and all it's child types like unit, item,...) can't be stored to a gamecache directly. Integers can. With the return bug we can convert handles to integers and vice versa. Example: Code:
function Unit2Integer takes unit u returns integer
return u
return 0
endfunction
function Integer2Unit takes integer i returns unit
return i
return null
endfunctionThe WC3 jass parser only checks the last return statement for a valid type. All other returns are ignored by it (possibly because this is the easiest way for Blizzard to allow returns without a value which exits the function). But at runtime the first return statement will be executed and return the specified value regardless of it's type. |
| 07-18-2004, 08:25 PM | #3 |
I see, that's why i haven't really understood what's so fantastic about gamecaches, since you previously could only store some values in it. Well, just after i posted this i read the transcript from weedars course and he also explained this. Anyways, thanks! EDIT: I cant't rep you since my browser is broken somehow so the command open in a new window won't function. Again, thanks. |
| 07-19-2004, 10:23 AM | #4 | |
Quote:
Probably you have some popup-blocker installed. Or is it really your browser? Note that some browsers have integrated popup blockers. |
| 07-19-2004, 08:15 PM | #5 |
No, there isn't a popupblocker or something like that, see the windows opens but it just stays blank, and gets the loading icon. You can go around this by pushing stop, which will make the adrees appear in the adreesfield and then you push update and tada! It works. Problems occur when you open windows which doesn't have a stop button. I know what the problem is, i went to IE support at microsoft.com and they had my problem described, you were to search for some files, and theese files were missing. They did not tell me how to fix it and since my IE is weird i can't uninstall it and reinstalling Windows isn't something i like to do, since it usually creates another problem or i miss to backup something etc. |
| 07-19-2004, 11:07 PM | #6 |
Is it possible to use the return bug with string to trigger? I'm having trouble getting it to work... Code:
//string to trigger conversion
function S2T takes string u returns trigger
return u
return null
endfunction
...
set trig[i] = S2T(SubStringBJ(dbutton[i], (StringLength(dbutton[i])-10), StringLength(dbutton[i])))
...a sample dbutton var set udg_DialogButtons[i] = "J|cFF0000FFJ|roingg_trg_Join" This string is basically the hotkey, dialog button text, and trigger activated by the button. I have the hotkey and dialog button text working, now I just need to fix the trigger. The text gets in ok, because I have a T2S() debugging message, but it just doesn't work. Any ideas? |
