Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

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

Posted

Have you tried the "convert to FM Text" command from TrFile? Wrap it like this:

 External("TrFile-ConvertToFMText", External("TrFile-GetContents", "C:path")) 

Posted

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

Posted

Lots of people in Vegas are using Troi File, eh? smile.gif Do you know of any way i can capture for that string in a FM function? I have to say that character sets are something i'm not at all familiar with.

Thanks for the help.

J

Posted

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.

Posted

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

Posted

If the following line always exists immediately after the Temp= 'line' how about finding 'Tmp=' (the start of the next line) and set the end of the line to be 3 chars less?

Steve

Posted

blush.gif Works perfectly. Silly me, muddling the issue with the extra characters that i didn't even need to worry about. mad.gif

Thanks a ton, Steve and Roger. I owe you both a beer.

J

This topic is 7489 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.