data_20without_20data
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| data_20without_20data [2018/03/31 13:19] – external edit 127.0.0.1 | data_20without_20data [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| //By JGH, May-2006.// | //By JGH, May-2006.// | ||
| + | <code bb4w> | ||
| DIM mon$(12) | DIM mon$(12) | ||
| RESTORE | RESTORE | ||
| FOR mon%=1 TO 12:READ mon$(mon%): | FOR mon%=1 TO 12:READ mon$(mon%): | ||
| DATA Jan, | DATA Jan, | ||
| + | </ | ||
| This has a few immediate disadvantages: | This has a few immediate disadvantages: | ||
| Line 11: | Line 13: | ||
| * The **DATA** pointer is modified, unless **LOCAL**ised | * The **DATA** pointer is modified, unless **LOCAL**ised | ||
| \\ You can avoid the **DATA** pointer being modified by doing the following: | \\ You can avoid the **DATA** pointer being modified by doing the following: | ||
| + | <code bb4w> | ||
| DIM mon$(12) | DIM mon$(12) | ||
| mon$() = ""," | mon$() = ""," | ||
| + | </ | ||
| but the data is still held in memory twice.\\ \\ An alternative for small bits of fixed data like this is to hold them in a string: | but the data is still held in memory twice.\\ \\ An alternative for small bits of fixed data like this is to hold them in a string: | ||
| + | <code bb4w> | ||
| DEF FNmon(mon%)=MID$(" | DEF FNmon(mon%)=MID$(" | ||
| + | </ | ||
| This has several advantages: | This has several advantages: | ||
| Line 20: | Line 26: | ||
| * The **DATA** pointer is not affected | * The **DATA** pointer is not affected | ||
| \\ This can even be done for data that at first sight doesn' | \\ This can even be done for data that at first sight doesn' | ||
| + | <code bb4w> | ||
| DEF FNmonth(mon%) \ | DEF FNmonth(mon%) \ | ||
| \ =MID$(" | \ =MID$(" | ||
| \ VALMID$(" | \ VALMID$(" | ||
| \ VALMID$(" | \ VALMID$(" | ||
| + | </ | ||
| The first **VALMID$** string is a series of initial start positions of the month name strings for each month. The second **VALMID$** string is the length of each month name.\\ \\ Note: the example functions only give valid results for valid month numbers. | The first **VALMID$** string is a series of initial start positions of the month name strings for each month. The second **VALMID$** string is the length of each month name.\\ \\ Note: the example functions only give valid results for valid month numbers. | ||
data_20without_20data.1522502354.txt.gz · Last modified: 2024/01/05 00:18 (external edit)