Recognize the device

I have a maybe silly question:

Some devices have the same screen resolution (e.g. Edge 530 and Edge 540) but are different to handle because of different fontsizes.

I do it by testing a teststring length by pixel to check which device it is. That works but I wonder:
is there no other possibility to ask which device it is?
All I found is DeviceSettings.partNumber, but that returns a string which (at first sight) has nothing to do with the device name.

  • All I was saying if it's something a bit non-typical in Monkey C, you may want to make sure it works in monkey c, as I've seen things that don't and sample code can live forever...  Slight smile

    I tried it with this in an app

            var str="abc";
    
            switch(str) {
                case "123":
                    System.println("found 123");
                    break;
                case "abc":
                    System.println("got abc");
                    break;
                default:
                    System.println("nothing");
                    break;
            }

    And it does work

  • Which device?  On the f7s. I found the height of FONT_NUMBER_MEDIUM was 68 in the sim while on a real f7s. it was 67

    Are all your device files for the sim current?

    My example with 64<>57 was for Edge Explore 2 which has same screen size as (old) Edge 1000.
    Yes, all devices are current.

  • Little bit off topic here - but:

    it's not easy to develop for a device you don't own.
    A user sent me screenshots from the real device so that I could "optimize" the layout.
    As described in the posts above: there is a huge difference in fontsizes and font-top-origins !

  • This isn't java or python, where you can do

    if(str="aBc")

    in both. I happen do be doing a bunch of Java and python right now. In Monkey C, to compare strings you need to use equal().  Kind of like of like C where you use something like strcmp()

    Java and Python are very different languages. In Java, it isn't the case *in general* that you can use "==" to compare two strings.

    Yes, due to Java string "interning", you can *usually* use "==" for comparison, but it doesn't always work. Of course, no one wants to write code that only works in a specific set of cases, which is why modern Java linters will flag the use of "==" for string comparison and ask you to use String.equals() instead.

    https://stackoverflow.com/questions/767372/string-equals-versus

    www.tutorialspoint.com/compile_java_online.php

    public class HelloWorld
    {
         public static void main(String []args) 
         {
             String a = "hello";
             String b = "hello";
             System.out.println("a: " + a); // "hello"
             System.out.println("b: " + b); // "hello"
             System.out.println("a == b: " + (a == b)); // true
             System.out.println("a.equals(b): " + a.equals(b)); // true
             
             String c = "hello";
             String d = "hell";
             d += "o";
             
             System.out.println("c: " + c); // "hello"
             System.out.println("d: " + d); // "hello"
             System.out.println("c == d: " + (c == d)); // false
             System.out.println("c.equals(d): " + c.equals(d)); // true
         }
    }

    I believe Monkey C designers were not so poor at making string comparisons in the switch by reference, not by actual value. With comparison by reference, it has pretty much no sense.

    Some people always think they know stuff which they don't, even to the point of posting replies which were already refuted by the comment they were replying to. e.g. You posted that Java is smart enough to compile switch statements with string cases so that String.equals() is used, so of course he had to reply that "but '==' works for comparing strings in Java!" (which isn't even true in general), as if he didn't even fully read what he replied to (which is often the case.)

  • If you were so smart you would have tried it in Monkey C if you've never used it, as I did to verify it worked...

    Or do you trust that everything works they way you think it should?  Are there no bugs in Monkey C?  Slight smile

  • Or do you trust that everything works they way you think it should?  Are there no bugs in Monkey C?

    Not sure. Every time I report a bug, a forum guru comes out of nowhere and tells me the problem is actually on my end, because Garmin can do no wrong in their eyes.

    If you were so smart you would have tried it in Monkey C if you've never used it, as I did to verify it worked...

    jim_m_58 avoid missing the point challenge (impossible)

    First of all, as SpitRider said, what he posted was pseudocode, so it doesn't really matter whether Monkey C supports string constants in case statements or not. As it turns out, it actually does. You're the one who claimed it doesn't though.

    Second, in an attempt to prove him wrong, you made incorrect statements about Java, as well as missing the point of what you were replying to.

    Third, you could've easily tried it in Monkey C yourself (before replying), to avoid "correcting" someone based on your own faulty assumptions (not the first time it's happened). You're the one making the claim that it doesn't work in Monkey C (despite the fact that it doesn't even matter here), I think the onus is on you to prove your own claim.

    It's not the first time you've arrogantly "corrected" someone or dismissed a bug report, and it turns out your own assumptions and "knowledge" were faulty. Pretty sure no matter how many times this happens, you'll never learn humility tho. Guess that's what happens when you've been coding since 1980 and you've decided there's nothing new for you to learn.

    Go back and read what you wrote:

    This isn't java or python, where you can do

    if(str="aBc")

    in both. I happen do be doing a bunch of Java and python right now. In Monkey C, to compare strings you need to use equal().  Kind of like of like C where you use something like strcmp()

    You're talking down to the person you're responding to without even understanding what they were trying to say:

    - that Java uses String.equals() when compiling case statements with string label
    - that they assume Monkey C does the same
    - that it doesn't matter since it was pseudocode in the first place, and not the main focus of discussion

    If you understood any of what they were saying, you wouldn't come back and say "monkey c isn't like other languages where you can use '==' to compare strings!" because that's clearly not the argument they were making.

    It's very clear from your tone that you think you know more than they do, and that nobody else can possibly teach you something you didn't learn on your own. And even as you talk down to people, you use incorrect "facts" (that java allows you to use "==" to compare strings.)

    Like wow, you "happen do be doing a bunch of Java and python right now". Too bad you clearly don't know the first thing about Java if you think you can use "==" to compare strings (in general). You also don't know enough to use a decent Java IDE with a linter that will prevent you from making that kind of mistake.

    If I were a noob coder, I would hate for you to teach me anything about Java, time zones, open-source software, IDEs, logic, deductive reasoning, reading comprehension (especially reading between the lines), clear and effective writing, or literally anything at all I would need to do my job.

  • If you were so smart you would have tried it in Monkey C if you've never used it, as I did to verify it worked...

    Also, why would I try it in Monkey C when you already did so, 4 hours before my first reply in this thread?