Jump to content

Troi File GetContents


This topic is 7234 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, all. Can anyone help me with the external TrFile-GetContents command? My problem (short version) is that i am unable to parse text properly because there is a strange endline character (i'm guessing it's some high-ASCII character) that FM's Left and Middle functions don't want to recognize.

The long version:

I am trying to retrieve environmental variables by creating a text file from the SET command, then pulling the contents of that file into a global field in my FM solution. I pull this in using

Set Field [ fieldName , External ( "TrFile-GetContents" , "C:filepathfilename.txt" ) ]

After this step, i now have the contents of that file in fieldName. I try to parse out the TEMP= variable from here by using the Middle function:

Middle ( fieldName , position ( fieldName , "TEMP=" , 1 , 1 ) + 5 , 64000 )

This now leaves me with a block of text that starts with "TEMP=" and continues on past that line onto other variables. But now (and here's my problem) i try to chop off the final part, the part after the actual TEMP variable, but i can't do this because the endline character there is some weird ASCII character i can't get my head around. No amount of copying and pasting is able to get me the proper terminal character, and copying that endline character to M$ Word and changing the font on it doesn't give me any insight into what it may be.

Any insight would be greatly appreciated.

Jerry

Link to comment
Share on other sites

Thanks for the suggestion, Roger. I forgot to mention that i did try that, but surprisingly i run into the same issue. Maybe this should lead me to conclude that it's not an ASCII thing but something else.

Another interesting side effect, which may amount to nothing more than a curiosity: If i copy the endline character and paste it into a text editor, it turns from one character into three (all of which look like that rectangle displayed when the character set has no mapping for that ASCII code). If i select all three of those characters in the text editor, only the first and last are highlighted; yet if i hit Ctrl-C and paste it somewhere else, all three characters are pasted, but again, only characters 1 and 3 are highlighted. Weird, no?

J

Link to comment
Share on other sites

What are you doing for the rest of the CRLF characters? I have not worked out the syntax but you could set the field to itself minus 2 characters (doesn't matter what they are) using Position and Length functions. Just shooting from the hip here... haven't worked it out.

Link to comment
Share on other sites

Yes, but it's not just the last two characters i need to cut off. What i want to do is isolate the line

TEMP=C:DOCUME~1jerryLOCALS~1Temp

which appears in the middle. So sometimes i'll need to drop the last 2 characters, sometimes the last 50, etc., depending on the system's environment variables.

The other CRLF characters are red herrings, because in my parsing i look for "TEMP=" and make that the starting point. Thus, it is only the CRLFs after that point that come into play. If the TEMP line were a fixed length, or had a known terminal string (such as "Temp"), that would make this easier, but that it is not always the case.

J

Link to comment
Share on other sites

This topic is 7234 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.