Shell help request: +weather text file writing
-
@Thenomain How about... I build that file with built-in same-file-size settings? That'll require a little bit of changing, hmm. So, here:
&FN.GETMOONPHASE Weather Code Framework=[setq(0, trim(extract(textfile(v(I.FILE) ,moon),3,1,;), b, _))][if(t(%q0), %q0%b)][trim(extract(textfile(v(I.FILE),moon) ,2,1,;), b, _)] &FN.GETMOONPERCENT Weather Code Framework=trim(extract(textfile(v(I.FILE),moon), 1,1,;), b, _)
And change the weather.php file at the very end to:
switch ($b) { case 0: $lunar_phase = 'New'; break; case 1: $lunar_phase = 'Crescent'; $waxingwaning = 'Waxing'; break; case 2: $lunar_phase = 'Quarter'; $waxingwaning = 'Waxing'; break; case 3: $lunar_phase = 'Gibbous'; $waxingwaning = 'Waxing'; break; case 4: $lunar_phase = 'Full'; break; case 5: $lunar_phase = 'Gibbous'; $waxingwaning = 'Waning'; break; case 6: $lunar_phase = 'Quarter'; $waxingwaning = 'Waning'; break; case 7: $lunar_phase = 'Crescent'; $waxingwaning = 'Waning'; break; default: $lunar_phase = 'Error'; } fputs( $fr, "\n& moon \n" ); fputs( $fr, str_pad($percentage, 3, "_")); fputs( $fr, ";"); fputs( $fr, str_pad($lunar_phase, 8, "_")); fputs( $fr, ";"); fputs( $fr, str_pad($waxingwaning, 6, "_"));
I'm not sure whether the rest of the PHP file needs to be changed or not - I'm not seeing any padding but the code seems to work okay.
-
@Thenomain said:
@Melpomene, Try it sometime. Manually change 'sunny' to 'partially cloudy' then type 'weather conditions' and it should cut off part of it.
Any time you change a server-side help or news file, you must re-run @readcache. N.b., TinyMUX or TinyMUSH. I don't know how Penn or Rhost deal with it.
No. Check it, yo:
@readcache goes through the textfiles and associates all & keywords with the byte location of the next line that doesn't begin with &. When the help file changes and the length of one article changes, the offsets of all the following articles will be off. If you have exactly one article in the text file this will never be a problem. It's also never a problem if you change the size of the last article in the file as there are no following articles.
-
@Sponge, thanks for making the technical clarification of the post I made on a phone at lunch. I'm sure the script can be improved, but as for how it was written you will need to read cache after running it. Helpful instruction remains. Also, on phone.
-
So, I tried all that and it didn't do the trick. I ended up just putting up a @readcache cron job every 30 minutes. All you who follow in my footsteps: skip the troubleshooting and just use the cron. @Sponge is wise.