Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

postition fails if occurrence is variable

Featured Replies

Several forum contributions quoted "position" formulations containing variables for occurrences.  I am at a loss why my simple script (FM 17, win10) containing a loop (stepwise increasing $i) which includes

Set Variable [$colon[$i]; Value: Position ( Filme::Besetzung; ":"; 1; $i)]

doesn't yield any result - unless I use numbers rather than the variable, testwise. (I wonder how to paste lines from the script here.) I assume I made an amateurish mistake and am looking forward to receiving advice of someone more experienced.

 

2 hours ago, ch53 said:

I wonder how to paste lines from the script here.

You can print the script to PDF and copy/paste from there. Or - much better - post a small file that shows the problem (and nothing else).

 

  • Author

thanks! I'd love to follow your advice, but could only do the pdf attachment. How to post the script? Sorry, I'm new here...

test script.pdf

I don't detect anything wrong with the script (other than that it doesn't do anything with the variables it populates). But that could be because I am reading the script, instead of running it. How did you determine that it "doesn't yield any result"?

  • Author

Thanks! In this part of the script, I meant to set $colon[1...$i] to contain the positions of ":" in the text "Filme:Besetzung", and $absatz the respective positions of the paragraph symbol.When I run data viewer in watch mode, $a and $i are correctly displayed, but nothing is given for $colon[$i] or $absatz[$i] unless I explicitly watch $colon[3], for example, to check the basic formulation, and then get the correct position number I counted in the text. It seemed so simple...

I am afraid I cannot reproduce the problem you report. I am attaching a simple file I made. In the last pause of the script, I see this in the Current pane of the Data Viewer:

image.png.d200578c0848fb460d3dca9701f1a484.png

and this in the Watch pane:

image.png.31ca012853567a44d0c8a345e9cae3d3.png

 

testing.fmp12

  • Author

More thanks! I restarted FM, and the computer, but both didn't help. Please find attached screenshots of the data viewer for loop runs 1 through 4. For now, I give up...

test01-04.pdf

I am afraid this is not moving us forward. Did you run my file? What results did you get? 

  • Author

OK! Now I tried it, and everything appears to be fine; same results as you showed. Can you possibly suggest anything else (apart from reinstalling the software)?

  • Author

More news: I ran the script on my old win7 PC, and it worked perfectly. Thus, I reckon I'll have to reinstall FM17, after all - but thanks anyway for your help and patience!

  • Author

After updating to 17.0.7.700, everything is fine. Grateful greetings and best wishes!

I am glad you got it sorted. As an aside, I am not sure what exactly you're trying to accomplish here, but I suspect there is a simpler way.

 

  • Author

Yes, probably you're right! In the text field the script is meant to work on, each line contains an actor's name, and the respective character in a movie, arranged in various ways, e.g. separated by a specific word ("as") or a colon, or with brackets around the characters. Sometimes, the names are first, sometimes the characters. I want to extract the names only and put them in a repetition field. (I know, users are discouraged to apply this feature, but I'd like nevertheless to keep this structure, rather than unravel and reorganize it.) The entire script has grown over time, with ever more versions of how names and roles are assembled in the movies' informations; that is why it certainly is somewhat discombobulated.

I too would recommend against using a repeating field for this. Splitting lines of text into separate related records is very easy, and you don't need to create repeating variables or find the positions of carriage returns for this. Just do something like:

Set Variable [ $n; Value:ValueCount ( YourTable::Textfield ) ] 
Loop
Set Variable [ $i; Value:$i + 1 ]
  Exit Loop If [ $i > $n ]
  Set Variable [ $line; Value:GetValue ( YourTable::Textfield ; $i ) ]

At this point the $line variable will hold the current line and you can go to the child table, create a new record and populate the name field with the name extracted from the $line variable. I am not sure how exactly to do the extraction, since you've listed several options but did not provide any rules for distinguishing among them. 

 

  • Author

Very kind of you, thanks! I'll let you know when the project is successfully finished!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.