Macromod Calculation Help

Discussion in 'Basic Tutorials' started by travellord, Feb 6, 2017.

  1. travellord

    travellord gℓσвεтяσттιηg ρяεsι∂εηт
    Builder ⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Jan 31, 2013
    Messages:
    328
    Trophy Points:
    36,540
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +91
    I'm working on macromod code that will allow me to do calculations that have decimals. However, I'm having trouble specifically with the MATCH command. I want to turn each digit into a separate variable so I can then manually insert a decimal point. However, I can't find any good documentation on the MATCH command so I've resorted to reading other macros for help and I'm lost.

    Code:
    $${
    #calc = 1/2
    if(#calc = 0)
        #calc = (1*10)/2
        #decianswer = #calc*251
        if(#decianswer < 100)
            &answer = 0.%#decianswer%
            log("%&answer%")
        elseif((#decianswer >= 100) && (#decianswer < 1000))
            &answer = %#decianswer%
            log("%&answer%")
        elseif(#decianswer >= 1000)
            match(%#decianswer%,^([0-9]+)([0-9]+)([0-9]+)([0-9]+), {#digit4, #digit3, #digit2, #digit1}) //This is where my problem is
            #wholeanswer = #digit4*100+#digit3*10+#digit2
            log("%#wholeanswer%.%#digit1%")
        endif
    endif
    }$$
     
  2. MaxToMinimum

    MaxToMinimum President
    President ⛰️⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Dec 25, 2013
    Messages:
    1,225
    Trophy Points:
    24,860
    Gender:
    Male
    Ratings:
    +313
    @priMELval
    I think she was doing a calculation macro, and is pretty good with macros
     
  3. BrokeMel

    BrokeMel broke
    Resident ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 26, 2013
    Messages:
    1,018
    Trophy Points:
    61,160
    Gender:
    Female
    Ratings:
    +830
     
  4. travellord

    travellord gℓσвεтяσттιηg ρяεsι∂εηт
    Builder ⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Jan 31, 2013
    Messages:
    328
    Trophy Points:
    36,540
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +91
    @priMELval I saw your calculator however I don't need a full calculator. I was trying to figure out how to extract portions of your code to use for just multiplying two numbers however the symbols in the MATCH portion were confusing to me so I decided I was just going to create one from scratch instead until I realized that I still needed the MATCH. It would be great if you could show me where you learned how MATCH and its contents work or just let me know. Thanks for the help though!
     
    #4 travellord, Feb 6, 2017
    Last edited: Feb 6, 2017
  5. BrokeMel

    BrokeMel broke
    Resident ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 26, 2013
    Messages:
    1,018
    Trophy Points:
    61,160
    Gender:
    Female
    Ratings:
    +830
    http://regexr.com/ is a fun website.
     
    • Informative Informative x 1
    • List
  6. travellord

    travellord gℓσвεтяσттιηg ρяεsι∂εηт
    Builder ⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Jan 31, 2013
    Messages:
    328
    Trophy Points:
    36,540
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +91
    @priMELval is that the language that macromod uses?
     
  7. BrokeMel

    BrokeMel broke
    Resident ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 26, 2013
    Messages:
    1,018
    Trophy Points:
    61,160
    Gender:
    Female
    Ratings:
    +830
    It's what the MATCH command uses.
     
  8. travellord

    travellord gℓσвεтяσттιηg ρяεsι∂εηт
    Builder ⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Jan 31, 2013
    Messages:
    328
    Trophy Points:
    36,540
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +91
    @priMELval thanks a lot thats exactly what I was looking for