1 2 Previous Next 23 Replies Latest reply on Feb 26, 2013 3:07 PM by Mitch

    Constructing various length text based on values

    Mitch

      Title

      Constructing various length text based on values

      Post

           Hi All,

           Not sure if this one can actually be done.  But here goes...

           I am trying to contruct text within a field, that includes spaces that is based on values from a table.  The text can be any number of characters long.

           The number of characters us already determined, and stored in a variable.  Lets say $Characters = 4.  I then have a loop that will run and exit after 4 cycles.  A loop can determine the required value of each of the 4 characters.

           How do I get these characters to be placed in a field as text or a word, in order from 1 - 4.  Also, can it it work if the characters varialbe is set at 12, with 12 loop cycles, therfore 12 characters, or even change to 1 character?

            

            

            

            

        • 1. Re: Constructing various length text based on values
          philmodjunk

               You've indicated how you will determine how many characters will be entered into the field, but not what will determine what character or characters will be entered into the field. How will you specify the characters?

               If the only one character is entered in a repeating pattern is to be entered such as:

               "xxx" ($characters = 3)

               or

               #####

               or

               99999999

               Then neither a looping script nor looping recursive custom function need be used to create such text:

               Here's a sample calculation that creates a repeating pattern of characters as specified in a variable named $RepeatChar:

               Substitute ( 10^$Characters - 1 ; 9 ; $RepeatChar )

          • 2. Re: Constructing various length text based on values
            Mitch

                 Phil,

                 Bascially the number of characters is determined by the number of charaters entered into an input field.  Lets say that the word entered into the input fieLd is 'B A S I C "; 5 characters:

                 B    

                 A    

                 S    

                 I    

                 C 

                 I need the script to look up a table and find the corresponding symbols for each leter:  B  A  S  I  C.  

                 Lets say its:

                 B = -

                 A = .. -

                 S = ...

                 I = -.-

                 C = . - .

                 The result is enteredt into an output field as:    -  ..-  ...  -.-  .-.  

                 Type a differant word into the input field, any length of charatcers and obviously get a differant result.

            • 3. Re: Constructing various length text based on values
              philmodjunk

                   Interesting. Morse Code translation?

                   If you have this relationship:

                   YourTable::globalLetter = MorseCode::Letter

                   Then the following script can loop through text entered into a field named "Clear", putting the looked up values in a field named "Code".

                   Loop
                     Set Variable [$K ; value: $K + 1 ]
                     Exit Loop If [ $K > Length ( YourTable::Clear ) ]
                     Set Field [ YourTable:GlobalLetter ; Middle ( YourTable::clear ; $K ; 1 ) ]
                     Commit Records
                     Set Field [YourTable::Code ; YourTable::Code & MorseCode::CodeCharacters ]
                   End Loop

                   This script assumes that you have one record in the MorseCode table for every possible character--even a space that might be entered into Clear.

              • 4. Re: Constructing various length text based on values
                Mitch

                     You are correct...

                     I will try this tonight.

                • 5. Re: Constructing various length text based on values
                  Mitch

                       Hi Phil

                       Just to clarify

                       Clear is the input field containing the word to be translated

                       Code is the output field with the translation

                       YourTable::GlobalLetter is the first table occurance, Letter Field (A, B C ...) ?

                       YourTable::Code is the first table occurance, Code Field (- , -.., ...- ) ?

                       YourTable::Code & MorseCode;;CodeCharacters ?

                        

                        

                  • 6. Re: Constructing various length text based on values
                    philmodjunk

                         That is correct and "globalLetter", while often a global field, need not be a global field as long as it is of type text.

                    • 7. Re: Constructing various length text based on values
                      Mitch

                           I am not sure of this table (Bold):

                            

                            Set Field [YourTable::Code ; YourTable::Code & MorseCode::CodeCharacters ]

                            

                            

                      • 8. Re: Constructing various length text based on values
                        philmodjunk

                             In what way are you "not sure"?

                             The expression appends the value of codeCharacters to the end of any text already present in Code.

                        • 9. Re: Constructing various length text based on values
                          Mitch

                               Ok,  will go back in a take anotehr look.


                               This is what I had so far:

                          Loop

                          Set Variable [$Loop; Value:$Loop + 1}

                          Exit Loop If [$Loop > Length 9Codes::gInput)]

                          Field [Codes::gGlobalLetter; Middle (Codes::gInput ; $Loop ; 1)]

                          Commit Records / Requests [No Dialog]

                          Set Field [Codes::gOutput; Codes::Code]

                                

                          Exit Loop

                                

                                

                          One Table named Codes

                          Two occurrences joined as Codes::gGlobalLetter = Codes::MorseCode

                          Codes::Char is the filed that contain the Alphanumeric letters (A, B, C ... )

                          Codes::MorseCode is the filed that contains the Morse Code (.._ , .-., ... )

                          Codes::gInput is the field that contains to word to be translated

                          Code::gOuput is the field that contains the translation in Morse Code

                                

                          The Table is from an external data source, using a script and ScriptParameter

                          • 10. Re: Constructing various length text based on values
                            Mitch

                                 Sorry Phil

                            Last line should be Set Field [Codes::gOutput; Codes Second Occurance::Code]

                                 I have it partially working, but it's only translating the last letter on the gInput Field.

                                  

                                  

                            • 11. Re: Constructing various length text based on values
                              philmodjunk

                                   That's not what I had.

                                   You need:

                                   Codes::gGlobalLetter = Codes 2::Char  (can't have the same occurrence name on both sides.)

                                   and if you want the entire text of gInput to appear converted into morse in goutput, you'll need this expression:

                              Set Field [Codes::gOutput; Codes::gOutput & Codes::Code]

                                   For the last set field step.

                                   It's unlikely that I would use the same data source table like this on both sides of the relationship as that doesn't make for a very clear relationship.

                              • 12. Re: Constructing various length text based on values
                                Mitch

                                     Phil

                                     I have placed a Cusom Dialongs after both the Set Fields steps in the Loop Script to show me what the sriot is doing.

                                     The srcipt is selecting the characters in the gInput Field, one by one as it should after the first Set Field step.

                                     However, the Code that is generated after the second Set Field step is the same Value for every charatcter....

                                     Any ideas for this obvious novice...?

                                      

                                   

                                • 13. Re: Constructing various length text based on values
                                  philmodjunk

                                       Please post the precise script that you now have:

                                       To post a script to the forum:

                                         
                                  1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                                  2.      
                                  3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
                                  4.      
                                  5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                                  6.      
                                  7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                                  • 14. Re: Constructing various length text based on values
                                    Mitch

                                          

                                          

                                              Loop

                                              Set Variable [ $Loop; Value:$Loop +1 ]

                                              Exit Loop If [ $Loop > Length (Codes::gInput) ]

                                              Set Field [ Codes::gGlobalLetter; Middle ( Codes::gInput ; $Loop ; 1 ) ]

                                              Commit Records/Requests [ No dialog ]

                                              Show Custom Dialog [ Title: "Message"; Message: Codes::gGlobalLetter; Default Button: “Close”, Commit: “Yes” ]

                                              Set Field [ Codes::gOutput; Codes::gOutput & Codes::Code ]

                                              Show Custom Dialog [ Title: "Message"; Message: Codes::gOutput; Default Button: “Close”, Commit: “Yes” ]

                                              End Loop

                                          

                                    1 2 Previous Next