• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

Using file/internet file plugin.

mrix

New member
I've tried to understand how to use regex a few time but for what i want to do its really simple - if anyone can help me i would appreciate it. Basically my Xpc constantly outputs a log file. It looks like this


Time ICE Aux Chipset System CPU Board CPU AGP +3.3V +5V +12V -12V RAM +5V SB Battery
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:50 1318 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:52 1325 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:54 1322 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:55 1323 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:57 1323 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:24:59 1323 0 0 38 39 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:25:01 1317 0 0 38 39 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:25:03 1321 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:25:05 1322 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:25:06 1325 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01:25:09 1324 0 0 38 38 35 1.440 1.440 3.216 4.892 11.968 1194.992 2.544 4.838 3.216
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


So i just want to be able to pick say colum #2 and colum #5 to display,
Whats the easiest way to do this?

thanks!
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

mrix

New member
Anyone?

I'm not sure how to make it search the last line. If i could do that then i could pick n "." and return characters before and after to get my numbers. Is there a tutorial on using this plugin? For what i want to do it seems like it should be relatively simple.

thanks again
 
I don't know anything about using regex, but if I had to parse those lines, I would use C.

I'd search each line, looking for " " (spaces) as delimeters for the fields, and just count the fields as each space is found. When a field I want is reached, I would use sscanf((char *)cp, "%f", (double) val) to extract a real (floating point) number.
 

jc634

Administrator
cosmicvoid is correct in the methodology. It has been far too long since I played with Regex to help much in the syntax area, tho. There are some examples in the User Screen Library sub-forum, which may give you some clues.

Also, you can Google/Bing Regex or Regular Expressions. Either one should give you hits on sites out there that provide everything your ever wanted to know about Regex and everything you didn't want to know, also.
 

CF Mark

Administrator
I use a free app called "RegexBuddy" to develop regular expressions.

I had a quick go at trying to devel an expression to do the above, but with no luck :(
 

starlon

New member
What implementation of regex does CC2 use? There's perl and another that I'm aware of. Perl's implementation would be easier to develop a regex for what you want to do due to the non-greedy specifier.

Something similar to:

/.*?\s(.*?).*?\s.*?\s(.*?)\s.*/

. = match anything
* = 0 or more matches
? = non-greedy, otherwise it would match everything till the very last white space

I don't know CC2's implementation though as far as referencing the extracted strings between the two sets of '(' and ')'. Probably something like %1 and %2, but I really don't know.

If it's not Perl, it becomes a little harder. Something along the lines of:

/\d+:\d+:\d+\s(\d+)\s\d+\s\d+\s(\d+).*/

\d = numeric digits
+ = one or more matches
\s = white space

CC2's implementation may not surround the regex with forward slashes.
 

mrix

New member
What language does the plug in use anyway?

im about to write an app in VB that does this for me and makes the information available to CC2 in some other way.. maybe just write a file for each variable i want
 
Top