Jump to content

Recommended Posts

My code opens a text file that is updated every 15 minutes and formats the values accordingly. My problem is that they now want to have the information displayed in a different order than what is being pulled from the text file. I'm a novice at PHP still and haven't been able to come up with how to get this accomplished.

They want to have the information displayed by Node in numerical order instead of however the information in brought in.

 

		$filename = 'TEST.TXT';
		$fp = fopen($filename, "r");

		$contents = fread($fp, filesize($filename));
		fclose($fp);

		$count = 1;
		$tok = strtok($contents, " \n");
		while($tok) 
		{
			switch ($count)
			{
				case 1:	$count++;
						break;
				case 2: if($tok == "AVAILABLE")
						{
							$tok = strtok(" \n");
							$tok = strtok(" \n");
						}
						if($tok >= $time)
						$time = $tok;
						$count++;
						break;
				case 3: if($tok == "MA06")
							$tok = "			<string>Node10</string> \n";
							if($tok == "HS02")
							$tok = "			<string>Node13</string> \n";
							if($tok == "MB08")
							$tok = "			<string>Node14</string> \n";
							if($tok == "RRG1")
							$tok = "			<string>Node28</string> \n";
							if($tok == "MVS1")
							$tok = "			<string>Node42</string> \n";
							if($tok == "HS01")
							$tok = "			<string>Node46</string> \n";
							if($tok == "MIX1")
							$tok = "			<string>Node49</string> \n";
							if($tok == "WIN0")
							$tok = "			<string>Node1</string> \n";
							if($tok == "XRC0")
							$tok = "			<string>Node2</string> \n";
							if($tok == "SYS6")
							$tok = "			<string>Node3</string> \n";
							if($tok == "DEV0")
							$tok = "			<string>Node4</string> \n";
							if($tok == "WIN5")
							$tok = "			<string>Node5</string> \n";
							if($tok == "CMC1")
							$tok = "			<string>Node6</string> \n";
							if($tok == "ARG1")
							$tok = "			<string>Node8</string> \n";
							if($tok == "OTI1")
							$tok = "			<string>Node115</string> \n";
							if($tok == "OTI3")
							$tok = "			<string>Node139</string> \n";
						$lpar .= $tok;
						$count++;
						break;
				case 4: if($tok == "999.9")
							$hint = "IPL being perfomed \non reporting lpar";
							if($tok < "999.9")
							$hint = $tok;

							if($tok == "999.9")
							$color = "009DFF";
							if($tok == "999.9")
							$tok = "100.4";

							if($tok >= "0" && $tok < "85")
							$color = "00B300";
							if($tok >= "85" && $tok < "90")
							$color = "FFCF21";
							if($tok >= "90" && $tok < "95")
							$color = "FF8620";
							if($tok >= "95" && $tok <= "100")
							$color = "FF0000";

						$spoolper .= "			<number bevel='data' tooltip='". $hint . "'>" . $tok . "</number> \n";
						$colorpic .= "		<color>" . $color . "</color> \n";
						$count = 1;
						break;
				default: break;

			} // end switch

			$tok = strtok(" \n");

		} // end while
			$spool .= "\n" . $lpar . "		</row> \n		<row> \n			<string>region A</string> \n" . $spoolper;
			$spool .= $filler1 . "<text transition='none' shadow='low' color='000000' alpha='100' size='12' x='374' y='467' width='100' height='50' h_align='left' v_align='top'>" . $time . "</text> \n" . $filler2;
			$spool .= $colorpic . "\n	</series_color> \n";
			return $spool;

 

Any help would be greatly appreciated.

Thank you.

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.