Difference between revisions of "Talk:Useful Scripts"
m
→Iterating through multiple lists: Fixing markup for an internal link
imported>Qazaaq (→License?: thanks!) |
imported>Cipscis m (→Iterating through multiple lists: Fixing markup for an internal link) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
:::Thank you for removing the line and for the scripts. | :::Thank you for removing the line and for the scripts. | ||
:::--[[User:Qazaaq|Qazaaq]] 23:27, 21 July 2009 (UTC) | :::--[[User:Qazaaq|Qazaaq]] 23:27, 21 July 2009 (UTC) | ||
==Category== | |||
Why are all the scripts placed in only one article? In the CS Wiki there is a category called useful code. There's also one on this Wiki. Can someone consider giving each script its own regular Wiki page and place them in the '''Category:Useful Code'''? | |||
[[User:Darkness X|Darkness X]] 11:21, 21 October 2009 (UTC) | |||
== Iterating through multiple lists == | |||
I've a couple of comments about the recently added script, [[Useful_Scripts#Iterating_through_multiple_lists| Iterating through multiple lists]]. | |||
First, I'm a little confused as to why variables are being used for [[Label]] and [[Goto]]. It is certainly not a requirement to use variables for label IDs. I would recommend just "hard coding" a number to use as each label's ID. For example, instead of: | |||
Label Label1 | |||
; ... | |||
Goto Label1 | |||
I'd recommend using: | |||
Label 10 | |||
; ... | |||
Goto 10 | |||
(I tend to use multiples of 10 in my initial write-ups of scripts, as this makes it easier to insert more loops later while maintaining a logical order of label IDs) | |||
More importantly, because labels' IDs cannot be higher than 255 (I thought I remembered this information being available on this wiki, but upon checking it wasn't. I have added it now) this script will no longer work after about 256 iterations, as the label's IDs will be higher than the maximum value of 255. | |||
I'd recommend using something closer to this, based on the template for ''for'' loops available on [http://cipscis.com/fallout/tutorials/loops.aspx| cipscis.com]: | |||
<pre>ref rOuterList | |||
ref rInnerList | |||
ref rCurrentRef | |||
int iOuterLength | |||
int iInnerLength | |||
int iOuterCount | |||
int iInnerCount | |||
set rOuterList to OuterList | |||
set iOuterLength to ListGetCount rOuterList | |||
set iOuterCount to 0 | |||
Label 10 | |||
if iOuterCount < iOuterLength | |||
set rInnerList to ListGetNthForm rOuterList iOuterCount | |||
set iInnerLength to ListGetCount rInnerList | |||
set iInnerCount to 0 | |||
Label 20 | |||
if iInnerCount < iInnerLength | |||
set rCurrentRef to ListGetNthForm rInnerList iInnerCount | |||
; Do Something with rCurrentRef | |||
set iInnerCount to iInnerCount + 1 | |||
Goto 20 | |||
endif | |||
set iOuterCount to iOuterCount + 1 | |||
Goto 10 | |||
endif</pre> | |||
Milo, please let me know if you have any comments or questions about what I've had to say. My aim is to help you improve your script, rather than replace it with my own. | |||
- [[User:Cipscis|Cipscis]] 20:44, 30 March 2011 (UTC) |