Duplicated the post here for posterity if someone or me ever needs some reminder of the power of strings
The is the module that i am using to build the weather zone list per zone it checks a pre-existing set of stringlists which are the weather tables you can see
here
Table 1 - 12 are weather tables for january to december and the columns go from
zone 1 - UK
zone 2 - Northern Europe
zone 3 - Norway/Finland/etc
zone 4 - Southern Europe
zone 5 - Spain/Italy/Balkans
zone 6 - Northern USSR
zone 7 - Southern USSR
zone 8 - Africa
then there are 10 rows each row representing 10% chance of certain weather.
Weather Types
0 - Clear
1 - Mud
2 - Snow
3 - Blizzard
So we started with
Tempvar900 - is 1-12 (the month) it's passed in from the originating function
StringList 0 - is the stringlist i'm calling 'Weather ForeCast' it holds the same style 8 columns to represent the forecast of the zones for turns ahead. It will allow us to have "Weather Forecasts" so commanders can have some foresight on how to position their forces. There will be a 35-40% chance that the weather on the turn itself is different then the forecast.
We're starting with 0 since vb.net uses 0 based numbering. Just something for non-developer types to take note of.
Then we're using CheckRandomRowStringList to pick a random # row from the strings just a row # not the contents of the number.
Then we have to set the same variable to the actual contents of that row.
0) ' This function opens the appriopriate weather list
1) SETVAR: TempVar901 = CheckRandomRowStringList(TempVar900, 0)
2) SETVAR: TempVar901 = CheckStringList(TempVar900, TempVar901, 1)
3) ' Weather For Zone 2
4) SETVAR: TempVar902 = CheckRandomRowStringList(TempVar900, 1)
5) SETVAR: TempVar902 = CheckStringList(TempVar900, TempVar902, 2)
6) ' Weather For Zone 2
7) SETVAR: TempVar903 = CheckRandomRowStringList(TempVar900, 2)
8) SETVAR: TempVar903 = CheckStringList(TempVar900, TempVar903, 3)
9) ' Weather For Zone 2
10) SETVAR: TempVar904 = CheckRandomRowStringList(TempVar900, 3)
11) SETVAR: TempVar904 = CheckStringList(TempVar900, TempVar904, 4)
12) ' Weather For Zone 2
13) SETVAR: TempVar905 = CheckRandomRowStringList(TempVar900, 4)
14) SETVAR: TempVar905 = CheckStringList(TempVar900, TempVar905, 5)
15) ' Weather For Zone 2
16) SETVAR: TempVar906 = CheckRandomRowStringList(TempVar900, 5)
17) SETVAR: TempVar906 = CheckStringList(TempVar900, TempVar906, 6)
18) ' Weather For Zone 2
19) SETVAR: TempVar907 = CheckRandomRowStringList(TempVar900, 6)
20) SETVAR: TempVar907 = CheckStringList(TempVar900, TempVar907, 7)
21) ' Weather For Zone 2
22) SETVAR: TempVar908 = CheckRandomRowStringList(TempVar900, 7)
23) SETVAR: TempVar908 = CheckStringList(TempVar900, TempVar908, 8)
24) EXECUTE: ExecMessage(999, 999, '0', '-1')
25) ' Add the row onto the end of the WeatherList
26) EXECUTE: ExecAddStringListCells(0, 1, 0)
27) LOOPER: TempVar0 FROM 1 TO 8
28) EXECUTE: ExecSetStringList(2, 2, 2, 2)
29) END LOOPER
Then with a little thinking that i could probably iterate over this more quickly and talking to
ernie I end up with a much smaller function.
0) ' This function opens the appriopriate weather list
1) ' it finds a random row then that row gets dumped into stringlist 0 which is weatherforcecast
2) ' Add the row onto the end of the WeatherList
3) EXECUTE: ExecAddStringListCells(0, 1, 0)
4) SETVAR: TempVar902 = CheckStringListRows(0)
5) ' Loop and generate the weather forecast
6) LOOPER: TempVar1 FROM 0 TO 7
7) SETVAR: TempVar901 = CheckRandomRowStringList(TempVar900, TempVar1)
8) SETVAR: TempVar901 = CheckStringList(TempVar900, TempVar901, TempVar1)
9) ' Add the results to the last row in the weatherforecast string
10) EXECUTE: ExecSetStringList(0, TempVar902, TempVar1, TempVar901)
11) END LOOPER