Jump to content

postition fails if occurrence is variable


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

Recommended Posts

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.

 

Link to comment
Share on other sites

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"?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

 

Link to comment
Share on other sites

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