Jump to content
JColeman

Scripting a loop using a value list

Recommended Posts

JColeman

Hi,

 

Don't know if this is possible or not, but....

We have a table containing various tidbits of project information, including the names of personnel who are the "project monitor" for respective projects. The personnel names are contained in a value list; when a new project is created, the name is chosen from the value list and plopped into the field. We periodically create reports summarizing the projects for each person. Is there a way to script report generation so that it will loop through the value list, automatically grabbing each person's name, and print the appropriate report? Currently, a user has to choose the name, then the report prints, then another name is chosen, report printed, and on and on. I guess it wasn't bad when there were two or three people; it's kind of tedious now that there are 7 or 8; will get worse as more are added. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
AHunter3

Sure!

 

Hmm, you really & truly using FmPro 7? Life is messier without $variables. Doesn't mean it can't be done though.

 

Create a pair of global fields, g.VL (text global field) and g.Pos (numerical global field).

 

Here's your script:

 

Set Field [Table::g.VL,"¶" & ValueListItems (Get(FileName), "YourLiteralValueListNameHere") & "¶"]

Set Field [Table::g.Pos, 1]

Loop

Exit Loop If [Table::g.Pos + 1 > PatternCount (Table::g.VL, "¶")]

.. Enter Find Mode []

.. Set Field [Table::Personnel Name, Middle (Table::g.VL, Position(Table::g.VL, "¶", 1, Table::g.Pos)+1, Position (Table::g.VL, "¶", 1, Table::g.Pos+1) - Position (Table::g.VL, "¶", 1, Table::g.Pos) -1)]

.. Set Error Capture [On]

.. Perform Find []

.. If [Get(FoundCount)>0]

.... Perform Script [Your Script that runs repot for current found record(s) goes here]

..End If

.. Set Field [Table::g.Pos, Table::g.Pos + 1]

End Loop

 

 

standard disclaimer: off the top of my head, not tested, will vouch for logic but typos may exist

 

EDITED 5/25/11 to get rid of spurious characters from changes in msg board software

Share this post


Link to post
Share on other sites
JColeman

Ingenious! Looks like it should work. Yes, I miss variables also. It's one of the things I miss about MSAccess and Visual Basic. I realize that's probably heresy on this forum, but.....

 

One question - I've seen several suggestions on this forum regarding the use of global fields to solve different situations. I realize the value of such things in accomplishing tasks and working around less-than-perfect data structures, but does adding such fields to a database compromise the integrity in any way? Are there any detriments to performance due to excessive use of storage space?

 

Thanks, and thanks for the script language.

Share this post


Link to post
Share on other sites
AHunter3

I've never had problems with globals. Since the debut of FileMaker 8 I don't use them anywhere near as much (variables made first appearance in Fm 8) but I had older solutions with dozens of them in each table w/o problem.

Share this post


Link to post
Share on other sites
ktalley

I know this is an old thread, but I am wanting to do a similar thing as the original poster (looping through a value list to and perform a find on each entry in the value list) except with Filemaker 9. I've not worked much with variables, so how would they make this process more efficient?

 

Thanks

Share this post


Link to post
Share on other sites
AHunter3

Well, you don't need global fields like g.Pos or g.VL.

 

Just define a $Variable whenever you need one. Don't need to define them as blank ("") to start with, the way you have to with global fields which might have something in them already. Much nicer that way!

 

ETA: There are also more specific functions for string parsing that were not available in FileMaker 6 and earlier, such as ValueCount and GetValue. But it's good to learn how to use Middle and Position anyhow since not every string you'll ever parse will be (or will easily convert to) return-delimited substrings i.e., "values".

Share this post


Link to post
Share on other sites
This thread is quite old. Please start a new thread rather than reviving this one.

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.   Paste as plain text instead

  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

Terms of Use