dbTalk Databases Forums  

Re: Scripting question re Loops

comp.databases.filemaker comp.databases.filemaker


Discuss Re: Scripting question re Loops in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Scripting question re Loops - 11-09-2005 , 11:06 PM






Max wrote:
Quote:
New to FM8 and still having a hard time with it.

So a question: is there a way to step through a value list in a loop? I would
like to be able to use FM8's ScriptMaker to do something like the following
using FM8's native scripting, not AppleScript. All of the items on the value
list and all of the output would be text values.

repeat with anItem in aValueList
doSomethingTo (anItem)
end repeat
Use the Loop script step -- something like this (not really
understanding what you're trying to do):

Set Field [gText, YourValueList]
Set Variable [$x = 0]
Set Variable [$y = valuecount(gText)]
Loop
New Record/Request
Set Variable [$x = $x+1]
Exit Loop If [$x > $y]
Set Field [MyTextField, getvalue(gText, $x)]
End Loop





--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Pro Solutions Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #2  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Scripting question re Loops - 11-09-2005 , 11:19 PM






Howard Schlossberg wrote:
Quote:
Max wrote:
New to FM8 and still having a hard time with it.
So a question: is there a way to step through a value list in a loop?
I would like to be able to use FM8's ScriptMaker to do something like
the following using FM8's native scripting, not AppleScript. All of
the items on the value list and all of the output would be text values.

repeat with anItem in aValueList
doSomethingTo (anItem)
end repeat

Use the Loop script step -- something like this (not really
understanding what you're trying to do):

Set Field [gText, YourValueList]
Set Variable [$x = 0]
Set Variable [$y = valuecount(gText)]
Loop
New Record/Request
Set Variable [$x = $x+1]
Exit Loop If [$x > $y]
Set Field [MyTextField, getvalue(gText, $x)]
End Loop
Just a quick note to my last post. Old habits die hard. I made
efficient use of variables in my sample script, but I included a global
field (gText) that could itself be a variable, as well.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Pro Solutions Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #3  
Old   
Michael Paine
 
Posts: n/a

Default Re: Scripting question re Loops - 11-10-2005 , 02:52 AM



If your value list is based on a table then you can use Loop Script step
to work though the records and "do something" with them. Search for
"Loop Script Step" in FM8 help (I find you usually need to guess the
search words well in order to locate appropriate help with FM8 howver
this time "repeat" turned up the Loop function).
The Value List should reflect any changes you make to the underlying table.
Note that with FM8 a table does not have to be "related" to other tables
in the database file. It can just be there for the purpose of value
lists or reference data.
Michael Paine

Max wrote:
Quote:
New to FM8 and still having a hard time with it.

So a question: is there a way to step through a value list in a loop? I would
like to be able to use FM8's ScriptMaker to do something like the following
using FM8's native scripting, not AppleScript. All of the items on the value
list and all of the output would be text values.

repeat with anItem in aValueList
doSomethingTo (anItem)
end repeat

Thanks for any suggestions.

Max


Reply With Quote
  #4  
Old   
ursus.kirk
 
Posts: n/a

Default Re: Scripting question re Loops - 11-10-2005 , 05:00 AM



Max,

To perform a find this way, you have to fall back into those old habits
Howard did mention. When the variable coontains the value you need, put this
value in a global field.

Set Field [ gMyGlobal ; $MyVariable ]
Enter Find Mode [] (Disable the pause)
Set Field [ MySearchField ; gMyGlobal ]
Perform Find

I did not include any errortrapping

Ursus


"Max" <max (AT) max (DOT) shack> schreef in bericht
news:4373105d$0$20233$8f2e0ebb (AT) news (DOT) shared-secrets.com...
Quote:
On Wed, 9 Nov 2005 23:19:59 -0600, Howard Schlossberg wrote
(in article <11n5m7qp8tajfd5 (AT) corp (DOT) supernews.com>):


Set Field [gText, YourValueList]
Set Variable [$x = 0]
Set Variable [$y = valuecount(gText)]
Loop
New Record/Request
Set Variable [$x = $x+1]
Exit Loop If [$x > $y]
Set Field [MyTextField, getvalue(gText, $x)]
End Loop


Thanks, Howard and Michael. Now I have the loop set up, and I'm
successfully
stepping through the text items of the Value List. My objective is to
automate a series of string searches, with the search criteria coming from
the Value List.

Unfortunately, I now realize that Perform Find seems only to accept text
as
criteria. For my script to work, I need it to accept variables. Yet when I
type in a variable ($gg), it just looks for the literal string "$gg." So
now
I'm hunting for a way around this.

Thanks again for help.

Max




Reply With Quote
  #5  
Old   
Dan Fretwell
 
Posts: n/a

Default Re: Scripting question re Loops - 11-10-2005 , 07:29 AM



I think you can remove the first Set Field and replace gMyGlobal by
$MyVariable in the second.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.