MU Soapbox

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Muxify
    • Mustard

    WTF And?

    MU Code
    5
    12
    2863
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Cobalt
      Cobalt Tutorialist last edited by Cobalt

      work I'm working on a code and I have logic of this number must be <=5 & >=0. When I test this out via thinking and(lte(5, 0), gte(0, 0)) it works fine, but in the code it returns false, so it fails.

      &c.+prefs/set prco=$+prefs/set *=*:@pemit %#=[setq(p, pmatch(%#))]
      			[if(u(fn.iscat?, %0),
      				[if(and(lte(5, %1), gte(0, %1)),
      					[alert(+Prefs)] Setting %0 to %1.
      					[set(%qp, 
      						_prefs.ratings:[get(%qp/_prefs.ratings)].%0:%1
      					)],
      					[alert(+Prefs, alert)] You tried to set '%1'.  You must set a rating of 0 to 5.
      				)],
      				[alert(+Prefs, alert)] I'm sorry but '%0' is not a category.  Check +prefs/list for available categories.
      				)]
      

      in fact this is what is happening in the guts:

      +Prefs Code Object <PrCO>(#248)} ‘lte(5, %1)’ -> ‘0’
      +Prefs Code Object <PrCO>(#248)} ‘ %1’ -> ‘3’
      

      Do I need to swap it around? Should be lte(%1, 5) ?

      1 Reply Last reply Reply Quote 0
      • ZekeTheG33k
        ZekeTheG33k last edited by

        Why not just do [gte ([match (1 2 3 4 5,%0)],1)]?

        Pay no attention to me. I'm old, jaded and generally unfriendly. I am prone to fits of stupidity, but I am still unique, just like everyone else. ~~ Current President of the Anti-Faraday fan club.

        Cobalt 2 Replies Last reply Reply Quote 0
        • Cobalt
          Cobalt Tutorialist @ZekeTheG33k last edited by

          @Seamus said in WTF And?:

          Why not just do [gte ([match (1 2 3 4 5,%0)],1)]?

          Because I'm not very familiar with match(), I don't think I've ever used it. And indeed I figured out the problem was that I had the numbers backward. It needed to be gte/lte(%1, 0/5) for the logic to work right.

          1 Reply Last reply Reply Quote 0
          • Cobalt
            Cobalt Tutorialist @ZekeTheG33k last edited by

            @Seamus said in WTF And?:

            Why not just do [gte ([match (1 2 3 4 5,%0)],1)]?

            But! Got any clever ideas on how to work with setting the data?

            It's currently stored like.

            _prefs.ratings: category:3.anothercategory:2.another:category:3

            I realized that set(%#, _prefs.ratings:[get(%#/_prefs.ratings)].%0:%1) won't work ... because what if they want to reset a pref they already have?

            I guess I'll have to add a thing in to see if that have that one set already... and then somehow replace it. :< (Oooooh, edit, will help there, yes, okay.)

            1 Reply Last reply Reply Quote 0
            • ZekeTheG33k
              ZekeTheG33k last edited by

              &fn`setstat <object>=[setunion([setdiff(<list of current stats>,<original stat>,<divider>)],<new stat>,<divider>)]

              That's a VERY VERY basic system for doing it.

              Pay no attention to me. I'm old, jaded and generally unfriendly. I am prone to fits of stupidity, but I am still unique, just like everyone else. ~~ Current President of the Anti-Faraday fan club.

              Cobalt 2 Replies Last reply Reply Quote 0
              • Cobalt
                Cobalt Tutorialist @ZekeTheG33k last edited by

                @Seamus Yeah that's what I've ended up starting to build up. I'm trying to think if there's a more graceful way to do it. I want to use edit() but ... I'd have to take out the delimiter. 😐

                1 Reply Last reply Reply Quote 0
                • Thenomain
                  Thenomain last edited by

                  Cobalt.

                  lte( 5, 3 )

                  Is 5 less than 3?

                  “If you wish to make an apple pie from scratch, you must first invent the universe.”
                  ― Carl Sagan, Cosmos

                  1 Reply Last reply Reply Quote 0
                  • Cobalt
                    Cobalt Tutorialist @ZekeTheG33k last edited by

                    @Seamus Okay got any clue why this is being weird?

                    &c.+prefs/set prco=$+prefs/set *=*:@pemit %#=[setq(p, pmatch(%#))]
                    			[if(u(fn.iscat?, %0),
                    				[if(and(lte(%1, 5), gte(%1, 0)),
                    					[alert(+Prefs)] Setting %0 to %1.
                    					[if(hasattr(%qp, _prefs.ratings),
                    						[if(u(fn.hascat?, %qp, %0),
                    							[alert(+Prefs)] Changing %0 to %1.[set(%qp, _prefs.ratings:[setdiff(get(%qp/_prefs.ratings), [graball(get(%qp/_prefs.ratings), %0, .)], .)].%0:%1)],
                    							[alert(+Prefs)] Setting %0 to %1.[set(%qp, _prefs.ratings:[get(%qp/_prefs.ratings)].%0:%1)]
                    						)],
                    						[alert(+Prefs)] Setting %0 to %1.[set(%qp, _prefs.ratings:%0:%1)]
                    					)],
                    					[alert(+Prefs, alert)] You tried to set '%1'.  You must set a rating of 0 to 5.
                    				)],
                    				[alert(+Prefs, alert)] I'm sorry but '%0' is not a category.  Check +prefs/list for available categories.
                    				)]
                    

                    It's returning:

                    :.+Prefs.: Setting action to 2.:.+Prefs.: Changing action to 2.
                    

                    I feel like it's a case of a missing coma or parenthesis but for the life of me I can't find it. 😐

                    1 Reply Last reply Reply Quote 0
                    • Cobalt
                      Cobalt Tutorialist last edited by

                      It's... like it's calling the code twice.

                      Mrrn.

                      1 Reply Last reply Reply Quote 0
                      • Cobalt
                        Cobalt Tutorialist last edited by

                        Aaaaand I found it!

                        Hello MSB! Welcome to "Cobalt knows what she's doing, honestly." masterpiece theatre.

                        1 Reply Last reply Reply Quote 1
                        • HorrorHound
                          HorrorHound last edited by

                          ...You are all Heretics, and meddle with The Warp! BURN!

                          shakes fist at

                          The Center Cannot Hold.

                          Chime 1 Reply Last reply Reply Quote 0
                          • Chime
                            Chime @HorrorHound last edited by

                            @HorrorHound said in WTF And?:

                            ...You are all Heretics, and meddle with The Warp! BURN!

                            Hail Tzeentch!

                            It is by will alone I set my mind in motion. It is by the juice of Coffea arabica that thoughts acquire speed, the table acquires stains, the stains become a warning. It is by will alone I set my mind in motion.

                            1 Reply Last reply Reply Quote 2
                            • 1 / 1
                            • First post
                              Last post