Jump to content
Sign in to follow this  
milefaker

set variable, value from external list

Recommended Posts

When using the "set variable" function, is it possible to select the value iteratively from an external list — i.e., not from a table within the database, but from either an external text file or from a multi-line list to be pasted into a dialog box by the user? Such a list would, ideally, hold one item per line or else be comma separated.

Thanks!

Edited by Guest

Share this post


Link to post
Share on other sites

Thanks. However, what you've referred me to "generates local variables from a text string without any prior knowledge of what those variables might be."

I don't need to generate the names of variable from a string; I'm trying to assign a list of text strings iteratively to the same variable. I've done this to date by importing a file of strings (one per line > one per record) into a separate temporary table, then assigning the contents of each record in that table successively to the variable, and finally deleting the temporary table. But I wonder if there isn't a more direct way to do this.

Share this post


Link to post
Share on other sites

This seems to be related to your other thread: GetValue with a field as parameter.

FileMaker dialogs don't handle multiple lines of text very well - you can paste the text in there but you only see one line. So you can do it that way, it's just not very elegant. I'd probably opt for a FileMaker layout-based "pseudo" dialog. That way you can make the text field as big as you want, give it a scroll bar etc.

Once the text is in the field just use GetValue( field; $i )

(the way you were going in the other thread, but you don't need the List function).

To read from a text file directly can be done with a plugin such as Troi File, or with AppleScript.

Share this post


Link to post
Share on other sites

Getting the values into a variable is a bit of a red herring. The tricky bit is getting text in an external file into FileMaker Pro. Putting it into a variable or a field is the easy part.

If it's going to be a regular thing then a third-party plug-in like troi file might be the best bet. The temporary table is also a good strategy but only if the imported files always have the same structure.

Pasting into a dialog (or a global field on a layout) would be the easiest option by far: once pasted into the global field the text can be processed with a script, or offered to the user for some cleaning up.

Share this post


Link to post
Share on other sites

Thanks for these suggestions.

If it's going to be a regular thing then a third-party plug-in like troi file might be the best bet.

It's going to be a regular thing, but I'm trying to avoid getting tangled up with plug-ins. Got to keep at this.

The temporary table is also a good strategy but only if the imported files always have the same structure.

The imported files will always have the same structure, but FMP doesn't seem to be able to Find data from one table within another.

Pasting into a dialog (or a global field on a layout) would be the easiest option by far: once pasted into the global field the text can be processed with a script, or offered to the user for some cleaning up.

It's not hard to paste the data into a global field, but the problem remains what to do with it then. I have set a variable equal to the contents of the global field and then tried to use GetValue to isolate individual sub-strings within it, but no matter whether separated by new-lines or semi-colons, it isn't working.

The simplest thing may just be to paste the data into one line of my script each time I need to search, but that's kind of surrendering.

Share this post


Link to post
Share on other sites

Despite your having two threads on the same subject, it is still not clear what are you actually trying to achieve.

Share this post


Link to post
Share on other sites

It's not hard to paste the data into a global field, but the problem remains what to do with it then. I have set a variable equal to the contents of the global field and then tried to use GetValue to isolate individual sub-strings within it, but no matter whether separated by new-lines or semi-colons, it isn't working.

It sounds like you need to learn some more about text parsing, because that's what your problem has resolved itself to now.

The GetValue() function works with values: strings of text separated with carriage returns. If your "sub-string" text isn't separated by carriage returns then GetValue() isn't going to do much for you.

It might be time to tell us what you want to do, not how you want to do it.

Share this post


Link to post
Share on other sites
It might be time to tell us what you want to do, not how you want to do it.
I wrote about two specific and different problems I had. Both are now solved through the same device; thanks for your help.

Share this post


Link to post
Share on other sites

Not really: in this post your question was "When using the "set variable" function, is it possible to select the value iteratively from an external list..."

What you want to do means a question like "I want to know how to update records in a database with a list of names in a text file on the hard disk".

We can only answer the question that is asked...

Share this post


Link to post
Share on other sites
in this post your question was "When using the "set variable" function, is it possible to select the value iteratively from an external list..." […] We can only answer the question that is asked.
In fact, I did ask exactly what I wanted to know, and you and the others did answer it. Again, I thank you for your time.

Share this post


Link to post
Share on other sites

Perhaps it could be beneficial to read this thread:

http://www.fmforums.com/forum/showtopic.php?tid/188219/fromsearch/1/hl/tokerud/tp/0/all/1/

...and it's linking to an older thread:

http://www.fmforums.com/forum/showtopic.php?tid/172514/

But as such do I subscripe to this in particular:

http://archive.eiffel.com/doc/manuals/technology/bmarticles/joop/globals.html

--sd

Share this post


Link to post
Share on other sites

In fact, I did ask exactly what I wanted to know, and you and the others did answer it. Again, I thank you for your time.

No you didn't - you disguised context and purpose in useless abstractions ... Vaughan is dead right here.

--sd

Share this post


Link to post
Share on other sites

Sorry — I didn't realize that the culture on this board favors whole-project questions. So far from trying to "disguise" anything, I was asking about the specific functions I was having trouble with, so as to keep discussion as narrowly on-topic as possible. In my field, it's considered rude to dump a whole problem on another person, and I was trying to show consideration by being as specific as possible about what I wanted to know. I'm sorry if I inadvertently gave offense.

****

Since you ask, the situation is this: The immediate application is to a database of Chinese sentences, in which I usually conduct searches for individual words and phrases — Chinese text does not have spaces between words or phrases, so I always build search-expressions with the asterisk-wildcard on either side of the word I am looking for.

I am suddenly faced with having to do these searches for a larger and larger number of words, and it is no longer feasible to do them manually. Hence the need for a script. However, the words I am searching for are only of interest transiently — there is no need for them to have their own permanent place in the database, either as records of their own or in additional fields within existing records. I tried creating a separate table for the search words to go into on a temporary basis, but was unable to find a way to use that table in constructing search expressions.

The way I am solving the problem now is by:

  • manually pasting a semicolon-delimited list of words into a Set Variable expression in the script
  • running a loop to find the search expression and output search results to a file named with the searched-for word
  • using ValueCount to determine the number of loop-iterations needed
  • because Find cannot use variables directly, the script has one step for Enter Find Mode, another step to Set Field to the variable holding the search term, and a third step to Perform Find; I'd like to know of a way to perform the find more economically, but so far this is the only way that seems to work

It is the first of these steps that I hoped I could automate more fully. A Cartesian join (described in this topic ) works well but takes a far far longer time to run. At the moment, doing the job with a manual paste in the first step (above), seems to be the most time-effective.

Thanks to all for their patient help.

Share this post


Link to post
Share on other sites

I was asking about the specific functions I was having trouble with, so as to keep discussion as narrowly on-topic as possible.

I just wondered where on earth you might track down such forums except among autists, where functions only have one single mode to be deployed in.

Functions in filemaker could to a linguist be compared with idioms, and if crucial elements are taken granted by the submitter, doesn't it necessarily mean the reciever would know how to weigh the absent and present elements against each other, the problem is that virtuous exercisers can due to their experience a handful of ways to do the same thing ... and it's here it gets circumstantial, which one suits the purpose.

But lets hear where you would find such a trivial pursuit'ish forum where only one single answer fits each question ... remember that each developer even have a signature way of development solutions unique to him/her. Lets get back to Babylonic confusion, what is directly translatable and what is not

the idioms for one is not!

--sd

Share this post


Link to post
Share on other sites

Sorry — I didn't realize that the culture on this board favors whole-project questions.

It doesn't necessarily. I thought your questions were reasonably clear.

I'd like to know of a way to perform the find more economically, but so far this is the only way that seems to work

It's the only way. FWIW, I generally prefer to use the Enter Find/Set Field/Perform Find steps even when a single Perform Find(restore) would do it, so I can immediately see what's going on when I go back to the script later.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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