10 Replies Latest reply on Dec 10, 2012 9:52 AM by ivanfernandez

    replacing one value for other with if

    ivanfernandez

      Title

      replacing one value for other with if

      Post

           i have no idea on how to use the filemaker sintax...

           i want to do this but i don't know how to code it... could you tell me where i can read a tutorial or give me the actual code for it? what i need is actually very basic i'll leave a pseudo code, thank you very much.

            

      if
      
             table1::item1 = "xx"
      
             table2::item1 = "xy"
      
      else if
      
             table1::item1 = "zz"
      
             table2::item1 = "xz"
      
      else if...
      
      end if

        • 1. Re: replacing one value for other with if
          philmodjunk

               And what is the relationship between table 1 and table 2?

               Could there be multiple records in table 2 related to a given record in table 1?

               or

               are you using this data to create a new record in Table 2?

               or

               is there always just one record in Table 2 related to to one record in Table 1?

               In general terms, you would either use a relationship between the two tables or you put the value from table 1 "xy", "xz"... in a variable, change layouts and then set the value to a field from the context of the second layout.

          • 2. Re: replacing one value for other with if
            ivanfernandez

                 Hi PhilModJunk, thank you for answering again :)

                 Going back to my URL problem i discovered a site where i can "index" the pictures, but each edition has a different route...

                 i have 2 tables, one with the name, edition, values of the card, etc... (stock) and one with the values to the URLs (ImagenesMagic)

                 the thing is, right now, to retrieve the pictures from the internet i have to manually input on each picture the path to the "folder" where the archives are stored and the name of the archive in two separate fields.

                 what i want is, by checking the "edition" field in table "stock" it gives the corresponding value to the editionUrl in table "ImagenesMagic"

                  

                 I've been doing some research and i tried this, but it gives me the error "the specified field was not found"

                  

            Set Variable [$edicion ; stock::edicion]
            Set Variable [$edicionUrl ; ImagenesMagic::EdicionUrl]
            
            if
                $edicion == "m12"
                $edicionUrl = "m12/largejpg"
                Set Field [ImagenesMagic::EdicionUrl ; $edicionUrl]
            end If

                  

                 I am trying to input this code in "file -> manage -> database -> fields -> options (on selected field) -> calculated value -> specify"

                 i think this is now the place... but then again i have no idea on where to look at, i tried on "file -> manage -> scripts -> new" but it doesn't lets me write directly and i don't know how to use it...

                  

                 I hope i have made myself clear enough as english is not my main language... if i had any mistakes or something was not explained well please let me know :)

                 Thank you very much for your help and your patience :)

            • 3. Re: replacing one value for other with if
              philmodjunk

                   The code you have posted is a script. You'd have to create this in Manage | scripts, then perform the script. You can't enter it as a calculation in the specify calculation dialog.

                   You also haven't answered the key question:

                   What is the relationship between the two tables?

                   If you have a relationship that matches one record in one table to exactly one record in the other table, then there are several ways to access the data in one table from the context of the other.

              • 4. Re: replacing one value for other with if
                ivanfernandez

                     i'm sorry, both tables are linked via the edition field... i think this would be better to explain it:

                      

                     STOCK                                         ImagenesMagic

                     ID                                                    ID

                     edition          ----------->                    editionStock

                     name                                               editionUrl

                     color                                                NameUrl

                     quantity                                           completeUrl

                     language

                      

                     thank you :)

                • 5. Re: replacing one value for other with if
                  philmodjunk

                       Does that mean that you have this relationship?

                       Stock::ID = ImagensMagic::ID

                       If so, you do not need to copy any data from one table to the other.

                       any time that you are on a layout for IamagenesMagic, you can refer to each and every field in Stock simply by placing the field on the layout.

                       Here's link that may help: Auto Fill

                  • 6. Re: replacing one value for other with if
                    ivanfernandez

                         i'm sorry but i just didn't understand the other post :(

                          

                         stock::ID = imagenesMagic::ID

                         stock::edicion has been formatted as a drop down list with values from imagenesMagic::editionUrl and values from stock::edicion

                         i added the imagenesMagic::editionUrl to my main layout

                          

                         yet when i input values no autofill is done...

                          

                         i'm very new to filemaker and i know i'm doing something wrong, i just don't know what.

                          

                         i really thought i could do this with a simple script with an if, else statement...

                          

                         this is a link to a copy of my file

                         http://lapetitmorte.com/stock.fmp12

                          

                         The file has some random data of a few cards already in.

                          

                         thank you for your help

                          

                          

                    • 7. Re: replacing one value for other with if
                      philmodjunk

                           You have this relationship:

                           Stock----ImagenesMagic

                           Stock::carta ID = ImagenesMagic::stockID

                           See this link if my notation is unfamiliar: Common Forum Relationship and Field Notations Explained

                           imagenesMagic::StockID is defined to auto-enter a serial number. carta has a unique values validation rule so there can only be one record in Stock that can link to any given record in ImagenesMagic using this relationship. For some reason, carta ID is a text field whil stockID is a number field--they should be the same type.

                           But NO record in Stock will link to ANY record in ImagenesMagic unless matching values are entered in carta ID and stockID.

                           

                                stock::edicion has been formatted as a drop down list with values from imagenesMagic::editionUrl and values from stock::edicion

                           I could not find any layout in this file where stock::edicion was formatted as a drop down list. Each one that I examined was an edit box.

                      • 8. Re: replacing one value for other with if
                        ivanfernandez

                             i didn't notice so many errors... i've been tinkering with it so much that i had no clue so many things were wrong...

                              

                             this is the updated file.

                              

                             i have changed cartas ID to auto enter serial and number type (thats how it should have been from the beginning), stockID now is only indexed from carta ID and the drop down list is now active in edicion.

                             the layout with it is the one called "stock"

                             the link is the same as before:

                              

                             http://lapetitmorte.com/stock.fmp12

                              

                             thank you :)

                              

                        • 9. Re: replacing one value for other with if
                          philmodjunk

                               Those value list settings do not look correct, but I'm not sure which options will work for you in this value list.

                               What do you want to see happen when you select a value from this drop down?

                          • 10. Re: replacing one value for other with if
                            ivanfernandez

                                 you were right the values on the list were not correct, i was not understanding the concept behind the dropdown list, i changed the concept and now is as i want it to be, this is the updated file (same link as before), if you are curious :)

                                  

                                 http://lapetitmorte.com/stock.fmp12

                                  

                                 thank you very much for your help and your patience