How not to maintain a news form



  • Fear my horrible code that doesn't remember what category it's supposed to be using for some reason. Although if someone can tell my why it doesn't I'll be eternally grateful. I have actually now rewritten this from scratch.

    <?php
        
    if ($_GET['id'] !== NULL) {
            
    validate_num($_GET['id'], 'id');
        }
        if (
    $_GET['id2'] !== NULL) {
            
    validate_num($_GET['id2'], 'id2');
        }
        
        if (isset(
    $_GET['id'])) $id $_GET['id'];
        if (isset(
    $id) AND preg_match ("/^([0-9]+)$/"$id)) {
            
    $sql 'SELECT  FROM '.TABLE_NEWS.' WHERE news_id = '.$id;
            
    $query $db->sql_query($sqlFILELINE);
            if ((
    $row $db->fetch_array($query)) !== false) {
                
    $text = ($row['news_details']);
                
    $extra = ($row['news_extra']);
                
    $name = ($row['news_name']);
                
    $column $row['news_cat'];
                
    $act $row['news_cat'];
            } else {
                echo 
    'Invalid ID: '.$id;
            }
            unset(
    $query);
        } else {
            
    $text firstslashes($_POST['text']);
            
    $extra firstslashes($_POST['extra']);
            
    $name firstslashes($_POST['name']);
            
    $column $_POST['column'];
            
    $act $_POST['act'];
        }
        
    $act = ($act) ? 0;
        
    $column = ($column) ? intval($_POST['column']) : 1;
        if (
    $act == 0) {
            
    $column 0;
        }
        if (
    $_POST['sub'] && strlen($name) > && isset($column) && strlen($text) > 1) {
            if (!isset(
    $_GET['id2'])) {
                
    $sql2 'INSERT INTO '.TABLE_NEWS.' ( news_namenews_detailsnews_extranews_catnews_datenews_act)'
                    
    .' VALUES ( ''.$name.'', ''.$text.'', ''.$extra.'', '.$column.', '.time().', '.$act.' );';
            } else {
                
    $sql2 'UPDATE '.TABLE_NEWS.' '
                    
    .'SET news_name = ''.$name.'', news_details = ''.$text.'', news_extra = ''.$extra.'', news_cat = '.$column.', '
                    
    .'news_act = '.$act
                    
    .' WHERE news_id = '.$_GET['id2'].';';
            }
            
    $db->sql_query($sql2FILELINE);
            if (isset(
    $_GET['id2'])) {
                echo 
    'Updated!<br />';
            } else {
                echo 
    'Posted!<br />';
            }
        } else if (
    $_POST['sub']) {
            
    $_POST['text'] = htmlentities($_POST['text']);
            echo 
    '<br />You are missing:<br /><br />';
            if (!
    $_POST['name']) echo 'Title<br />';
            if (!
    $_POST['column']) echo 'Category<br />';
            if (!
    $_POST['text']) echo 'Text<br />';
        }
        
    $sql3 'SELECT 
     FROM '
    .TABLE_CAT.';';
        
    $query $db->sql_query($sql3FILELINE);
        while ((
    $row $db->fetch_array($query)) !== false) {
            if (
    is_array($news) AND $news[0] != AND !in_array($row['cat_id'], $news)) continue;
            if (
    $row['cat_id'] == $column) { $check ' checked="checked" selected="selected"'; }
            else { unset(
    $check); }
            
    $checks[] = '<input type="radio" name="column" value="'.$row['cat_id'].'"'.$check.' /> &nbsp; '.$row['cat_name'].'<br />';
        }

        if (
    $_POST['act'] || !isset($id)) { $check ' checked="checked" selected="selected"'; }

        if (isset(
    $_GET['id2'])) $id $_GET['id2'];
        
    $idp = (isset($id)) ? '&amp;id2='.$id '';
        echo 
    '<form method="POST" action="'.FILE.'?action=news'.$idp.'">
                <input name="name" type="text" value="'
    .stripslashes($name).'" size="45"><br>';
        
    array_to_table($checks'''left');
        echo 
    '<textarea name="text" cols="110" rows="15">'.stripslashes($text).'</textarea><br>
                Extra Information:<br />
                <textarea name="extra" cols="110" rows="15">'
    .stripslashes($extra).'</textarea><br>
                <input type="checkbox" name="act" value="1"'
    .$check.'> &nbsp; Activate News (Disabling this hides the news)<br />
                <input type="submit" name="sub" value="Submit">
            </form>'
    ;
    ?>



  • My mother told me that if I didn't have something nice to say, I shouldn't say anything at all. And boy do I ever have a lot of nothing to say...



  • If you have rewritten it, then what is the point of knowing where it fails?



  • @dhromed said:

    If you have rewritten it, then what is the point of knowing where it fails?

     Not having to rewrite a page because of the same mistake ?



  • TABLE_CAT



  • ExcessiveColourException at forums.thedailywtf.com/forums, post 130043



  • @Zecc said:

    ExcessiveColourException at forums.thedailywtf.com/forums, post 130043
    You object to syntax coloring?



  • I object to red, green and blue syntax coloring. Specifically <font color="#ff0000">red</font>.

    Syntax coloring is useful for mental parsing, but not when it <font color="#ff0000">hurts</font> <font color="#00cc00">the</font> <font color="#0000ff">eyes</font> <font color="#00ff00">and </font><font color="#ff0000">confuses</font> <font color="#0000ff">the </font><font color="#ff0000">brain</font>. Mine, anyway.



  • I will change my syntax colouring to use greyscale tones from now on.



  • I must be crazy to actually react to this, but since my eye fell on it...

                 $column $row['news_cat'];
     
    [...snip...]
        } else {
    [...snip....]

            
    $column $_POST['column'];

    [...snip...]
        $column = ($column) ? intval($_POST['column']) : 1;

     

    Now, that's never going to work. Obviously. 



  • @dhromed said:

    I will change my syntax colouring to use greyscale tones from now on.

    I'm just saying you don't need agressive colors, that's all.  E.g. http://www.movabletype.org/2007/06/syntax_highlighting.html

     The font type makes it worse, I guess.
     



  • @Zecc said:

    @dhromed said:

    I will change my syntax colouring to use greyscale tones from now on.

    I'm just saying you don't need agressive colors, that's all.  E.g. http://www.movabletype.org/2007/06/syntax_highlighting.html

     The font type makes it worse, I guess.

    I find any attempt to use syntax colouring on a white background is highly likely to make a mess. It works vastly better on grey or black - something about relative contrast, I never did pay much attention in colour theory lectures. It's also easier on the eyes, since it radiates less energy.

    Of course, the best approach is to use both foreground and background colours. For example, if you colour comments and strings by using different shades of grey for the background (and normal foreground text), then it's both really obvious and really easy to read, you don't have huge colour splashes all over the place (since those two make up the vast majority of the coloured text in typical code), and you've got two more colours to use for important things. As an added bonus, embedded $vars in languages like perl colour much more clearly.



  • Case in point: [URL=http://img102.imageshack.us/my.php?image=untitleduu9.png][IMG]http://img102.imageshack.us/img102/4516/untitleduu9.th.png[/IMG][/URL]

    I prefer (by default, because I've never tried otherwise) a white background. I keep the luminosity and monitor low.

    I never use light colors for text, except eventually comments.

     

    And that's enough discussion of the topic for me. 



  • Double post

    I keep the luminosity and contrast of the monitor low.

    Wretched edit timeout. Thwarted me again!



  • @dhromed said:

    If you have rewritten it, then what is the point of knowing where it fails?

    The entire thing is a flurry of mistakes, and the column forgetting is the only mistake I haven't figured out, which means I am more likely to repeat it.



    As for the colors, sorry, I won't pipe the code (presuming it's PHP again) through highlight_file, although the output it produces is kinda a wtf of it's own.



  • @Zecc said:

    Case in point: [URL=http://img102.imageshack.us/my.php?image=untitleduu9.png][IMG]http://img102.imageshack.us/img102/4516/untitleduu9.th.png[/IMG][/URL]

    I prefer (by default, because I've never tried otherwise) a white background. I keep the luminosity and monitor low.

    I never use light colors for text, except eventually comments.

     

    And that's enough discussion of the topic for me. 

     

    I prefer a grey background, with black text, and muted colors for highlighting.  It'll save your eyes when you have to stare at the damned thing for 8 hours a day... 



  • Wait, don't tell me... You use the same colours as this site so that people don't notice when you're procrastinating. :)



  • @Zecc said:

    Wait, don't tell me... You use the same colours as this site so that people don't notice when you're procrastinating. :)

     

    Shhh... you'll blow my cover. 



  • So... let's see.

     

    1. if ($_GET['id'] !== NULL)

    why not just use isset($_GET['id']) like you do a few lines later? Exactly the same thing and far more readable with isset().

    2. if (isset($_GET['id'])) $id = $_GET['id'];

    You just did this test earlier. Go for:

    if (isset($_GET['id'])) {
       validate_num($_GET['id'], 'id');
       $id = $_GET['id'];
    }

    unless validate_num() is doing something funky like overwriting what's in $_GET, which I see you do for other values elsewhere.

    3. You're blindly assuming that if $_GET['id'] isn't set, you're doing a POST and slurping data from $_POST.

    how about:

    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
      .... do get stuff here ....
    } else {
      .... do post stuff here ...
    }

     
    4. if ($_POST['sub']] && etc...
         if (!isset($_GET['id2'])

    Generally $_GET will be empty if you're doing a post, unless you're passing GET parameters in the <form action="script.php?yada=yada"> tag, which is weird. Why not just embed whatever you're passing as hidden fields inside the post form?

    5. $_POST['text'] = htmlentities($_POST['text']);

    Don't overwrite contents of $_POST (or _GET or _REQUEST for that matter). It's bad form. Just save whatever you're doing into an intermediate variable and use that wherever you have to. 

    6. $text = firstslashes($_POST['text']);

    Not a standard function, what's it doing? Undoing magic_quotes_gpc? Escaping stuff for later insertion into the DB, which you're doing a few lines later? For one, depending on magic_quotes_qpc being on is STUPID. What if this runs on a host where it defaults to off? Don't write your own escape functions either. I don't recognize which DB library you're using there, but any such library that's worth not shooting in the head will have its own escape function already there.

    7. $sql2 = 'INSERT INTO'.TABLE_NEWS.' (etc...) .'VALUES ('''.$name.''. '\ etc...

    Learn how to use heredocs. This is FAR FAR FAR more readable as

    $x = TABLE_NEW; 

    $sql = <<<EOL
    INSERT INTO $x VALUES (...fields...) VALUES ($name, $text, etc...)
    EOL

    or better yet, use prepared statements, if your DB library supports that.

    8. At one point you do $text = firstslashes(), and later on do stripslashes($text). If $text gets to be large, then you're doing, and UNDOING, a large amount of work. If you're going from state A to state B, and then back to state A, keep a copy of the original state A and save state B into a different variable. That way you only do the work once, and everyone's happy. Unless text is so large you can't afford the extra memory usage, of course.


    9. As for the rest, do your own homework :)



  • I may as well try and explain why some things are as they are. Thank-you MarkB for spending the time to write something that thorough. Also thank-you Monomelodies for noticing that categories issue.



    > why not just use isset($_GET['id']) like you do a few lines later? Exactly the same thing and far more readable with isset().

    This was written hack after hack; I was the only coder so I didn't follow any standard, also this was actually one of my first programs.

    I agree though, I should have really refactored this.



    > You're blindly assuming that if $_GET['id'] isn't set, you're doing a POST and slurping data from $_POST.

    > Generally $_GET will be empty if you're doing a post, unless you're passing GET parameters in the <form action="script.php?yada=yada"> tag, which is weird. Why not just embed whatever you're passing as hidden fields inside the post form?

    Undocumented: If _GET['id'] is set then it's editing an old post, other-wise it's posting a new post or editing that new post if an error occurred.

    > Not a standard function [firsdtslashes()], what's it doing? Undoing magic_quotes_gpc? Escaping stuff for later insertion into the DB, which you're doing a few lines later?

    Actually first slashes is basically: return (if magic_quotes_gpc is on) ? $str : addslashes($str);

    stripslashes is called later because the data it's called on has been escaped already,for insertion into the DB, but I need to display it in the form because it's either for editing or fixing an error.

    > For one, depending on magic_quotes_qpc being on is STUPID. What if this runs on a host where it defaults to off? Don't write your own escape functions either.

    My test server has it as off because I don't always put GET and POST data into a DB, sometimes I put it into a file where having those slashes is annoying. The server it was built for has it on.

    >I don't recognize which DB library you're using there, but any such library that's worth not shooting in the head will have its own escape function already there.

    Homebrew, it sucks horrible chunks. It's actually the one that calls the error system (a die wrapper really), hence why it needs FILE and LINE. I use MDB2 now.

    > or better yet, use prepared statements, if your DB library supports that.

    Didn't know they existed at the time. I just recently got a book that taught me about PEAR::DB which is apparently usurped by MDB2.





    Also validate_num is probably a mini-wtf on it's own (it's like 10 lines iirc), it will die if it doesn't receive a number as the first parameter. Since I don't have immediate access to all my old source (I have more hard-drives than I have computers capable of reading them all, each one is partitioned at least thrice). I really need to start labeling my stuff.



  • @Zecc said:

    Case in point: [URL=http://img102.imageshack.us/my.php?image=untitleduu9.png][IMG]http://img102.imageshack.us/img102/4516/untitleduu9.th.png[/IMG][/URL]

    I prefer (by default, because I've never tried otherwise) a white background. I keep the luminosity and monitor low.

    I never use light colors for text, except eventually comments.

    And that's enough discussion of the topic for me.

    I find that screenshot a flurry of bolds, cursives and colours.

    My editor, Editplus, doesn't support anything but colours. Maybe it'd be a good thing if it'd support background colouring.

    But anyway, I have a different colour scheme per language, mostly because I can. It seems many editors specify colouring for common syntaxt-objects like strings, keywors, variables, preproc directives, and I don't mind that, but I like it that PHP looks blueish,  JavaScript is green and yellow,  HTML is blue and orange, CSS green and red. Added recognitio speed of what I'm looking at.

    I also use soft background tones for current-line and matching-bracket. I hate it when an editor bolds or (ack!) outlines the {, deforming it and making it less recognisable.



  • One other WTF I see...  look into using smarty templates or something - mixing html and domain logic code is bad form.  Look up MVC architecture.  It really helps clean up code and makes bugs easier to find.



  • In the words of Elvis Costello, I just don't know where to begin.

    • You are having problems with your code because it lacks structure and discipline
    • The nature of your code dictates that you will rapidly lose the ability to support or modify what you have done
    • A quick fix from someone here will not address the root cause of your problem
    • If you continue to code this way you will consistently find yourself unable to deliver working solutions

    Developing code discipline is not difficult. You could start by asking yourself why you are using the ternary operator. Think about how breaking your code into functions might make your code more abstract, less fine-grained. Consider using the new comment syntax, recently introduced in PHP version 1.0. Overall, try to imagine that you are writing code that a reasonably bright twelve-year old child should be able to understand.

    Learning to write coherent code is a wonderful skill that will repay you for the rest of your life. It will make you more capable, more efficient and considerably more popular with your colleagues. You might want to start with your variable names.



  • Cosmo7, I believe you misunderstood me slightly. Although I appreciate the comment, I have already rewritten the code, as mentioned before I was only curious about the category bug because last time I modified the code (well over two years ago) I was struggling to find out the source of said bug. Something that a debugger would catch.


    For the curious, the revised version (post only). The only WTFs I see are magic numbers (don't care about fixing that) and really non-friendly errors (So far no complaints).

    function NewsPost($user_id, $title, $data, $extra, $category, $act = 1) {
    global $db;
    if (!is_object($db)') {
    die('FATAL: $db is not valid.');
    }
    if (3 > strlen($title) || strlen($title) > 127) {
    return 'Title length out of bounds(3, 127).';
    }
    if (strlen($data) < 10) {
    return 'Body length is too short.';
    }
    if (!is_numeric($category)) {
    return 'category is invalid. '.var_export($category, true);
    }

    $date = time();

    $fields = 'news_user, news_cat, news_name, news_details, news_extra, news_date, news_act';
    $data = array($user_id, $category, $title, $data, $extra, $date, $act);
    $types = array('integer', 'integer', 'text', 'text', 'text', 'integer', 'integer');
    $post = $db->prepare('INSERT INTO `bp_news` ('.$fields.') VALUES (?, ?, ?, ?, ?, ?, ?)', $types);
    if (PEAR::isError($post)) {
    die($post->getMessage());
    }
    $post->execute($data);
    if (PEAR::isError($post)) {
    die($post->getMessage());
    }

    return $db->lastInsertID('bp_news');
    }

    Quote for indent.


  • @Zecc said:

    Case in point: [URL=http://img102.imageshack.us/my.php?image=untitleduu9.png][IMG]http://img102.imageshack.us/img102/4516/untitleduu9.th.png[/IMG][/URL]

    I prefer (by default, because I've never tried otherwise) a white background. I keep the luminosity and monitor low.

    I never use light colors for text, except eventually comments.

     

    And that's enough discussion of the topic for me. 

    I like that font though. What's its name?



  • @PSWorx said:

    I like that font though. What's its name?

    Dina programming font (at 8pt). The screenshot is of Notepad++, though I usually use PSPad more, for some reason, and sometimes Notepad2.

    I like Proggy Clean (Slashed Zero) too, which I used before Dina.

    PS: my Firefox crashed for no apparent reason. Thank divinity of your choosing for "Session Restore".



  • Thanks very much!



  • @Zecc said:

    @PSWorx said:

    I like that font though. What's its name?

    Dina programming font (at 8pt).

    Looks to me remarkably like good old misc-fixed 7x14 or 10x20 (only not quite as sharp, since it's truetype). If you think that's p8 then you're either using Windows or a display with an unusually high DPI, I measure it at about p12, roughly the same as 7x14.

    (And incidentally, pt is short for points, but it means the kind of points that are used as a measurement of the thickness of cardboard, and is entirely unrelated to the points used to measure typefaces: 1pt is 1/1000 inches, while p1 is 1/72 inches on the modern scale)



  • @asuffield said:

    (And incidentally, pt is short for points, but it means the kind of points that are used as a measurement of the thickness of cardboard, and is entirely unrelated to the points used to measure typefaces: 1pt is 1/1000 inches, while p1 is 1/72 inches on the modern scale)

     "pt" is a commonly used abbreviation for the typographical point as well. I've never heard of "pNN" for font sizes.
     



  • Yes, I'm using Windows. I guess I should have just said "size 8". It's about the same as Proggy's "size 10".

    Because I'm bored at work, here's a treat:

    [URL=http://img182.imageshack.us/my.php?image=fonttestns7.png][IMG]http://img182.imageshack.us/img182/8189/fonttestns7.th.png[/IMG][/URL] 



  • @Random832 said:

    @asuffield said:

    (And incidentally, pt is short for points, but it means the kind of points that are used as a measurement of the thickness of cardboard, and is entirely unrelated to the points used to measure typefaces: 1pt is 1/1000 inches, while p1 is 1/72 inches on the modern scale)

    "pt" is a commonly used abbreviation for the typographical point as well. I've never heard of "pNN" for font sizes.

    It's common for a great many other things too, as Wikipedia tells us.

    Wikipedia also tells us that 5p means 5 points, 6p5 means 6 pica 5 points, and that the syntax "5pt" for 5 points is merely "common".

    But I'm a use "5pt" anywayz. 



  • @Zecc said:

    Yes, I'm using Windows. I guess I should have just said "size 8". It's about the same as Proggy's "size 10".

    So many programs in windows assume points = pixels. Windows defaults to 72 dpi, and changing it makes everything specified in "points" scale, and everything specified in "pixels" stay the same size. Most non-Microsoft programs f*** up completely, because you get window sizes specified in pixels with buttons sized in points, or a label sized in pixels with the font on it in points, so you can't read half of it.

    No wonder people lower the resolution to make everything larger instead of setting the dpi correctly.

    EDIT: IIRC VB.net confuses the issue by working in typographic points (1/1000th inch) instead of the "cardboard points" that the rest of windows uses (1/72nd inch).



  • @Random832 said:

    @asuffield said:

    (And incidentally, pt is short for points, but it means the kind of points that are used as a measurement of the thickness of cardboard, and is entirely unrelated to the points used to measure typefaces: 1pt is 1/1000 inches, while p1 is 1/72 inches on the modern scale)

     "pt" is a commonly used abbreviation for the typographical point as well. I've never heard of "pNN" for font sizes.

    "Kg" is a commonly used abbreviation for kilogrammes. Both are wrong. No matter how many people use it, it will always be wrong. Units are not defined by popularity: that way leads to chaos and madness, as any country more than a millennium old can attest. Standard names for units is not just a good idea, it's the law.

    XpY is the standard abbreviation for writing sizes measured in picas, where X is picas and Y is points, but most people just write "8 points" in software. Pica measurements are only typically used in serious typesetting, not the desktop stuff.



  • @Thief^ said:

    @Zecc said:

    Yes, I'm using Windows. I guess I should have just said "size 8". It's about the same as Proggy's "size 10".

    So many programs in windows assume points = pixels. Windows defaults to 72 dpi, and changing it makes everything specified in "points" scale, and everything specified in "pixels" stay the same size. Most non-Microsoft programs f*** up completely, because you get window sizes specified in pixels with buttons sized in points, or a label sized in pixels with the font on it in points, so you can't read half of it.

    No wonder people lower the resolution to make everything larger instead of setting the dpi correctly.

    The real problem is that Windows entirely fails to correct for the DPI of the display device (ie, your monitor), which is typically 100dpi (ie, nowhere near the choices they normally offer of 72dpi and 120dpi). It is supposed to correct for this ever since windows 95, but that feature has never worked, and nobody at Microsoft seems to have the slightest interest in fixing it. The result is that the point sizes quoted by windows applications aren't even remotely close to the actual size of the fonts displayed, so now we have an entire generation of windows users who are confused about how big a point is. Even some of the printer drivers now get it wrong, leading to all sorts of strange results as documents are printed on different printers.

     

    EDIT: IIRC VB.net confuses the issue by working in typographic points (1/1000th inch) instead of the "cardboard points" that the rest of windows uses (1/72nd inch).

    Other way around. Typeface points are 1/72 inches.



  • @asuffield said:

    @Random832 said:
    @asuffield said:

    (And incidentally, pt is short for points, but it means the kind of points that are used as a measurement of the thickness of cardboard, and is entirely unrelated to the points used to measure typefaces: 1pt is 1/1000 inches, while p1 is 1/72 inches on the modern scale)

     "pt" is a commonly used abbreviation for the typographical point as well. I've never heard of "pNN" for font sizes.

    "Kg" is a commonly used abbreviation for kilogrammes. Both are wrong.

    There is a very big difference between "This is the only valid abbreviation for this unit" (which, the standardization body defining a unit of measurement has the authority to do) and "This abbreviation is reserved for this unit and may not be used to refer to any other unit" (which, outside of being in the same system of measurement, they do NOT). Also, only the metric system has widespread (spanning multiple industries and codified by something more than common usage) standardized abbreviations, and neither of these units is part of the metric system.

    An abbreviation for point (1/72 inch) is "pt"

    An abbreviation for pica (1/6 inch) is "pc"

    An abbreviation for point (1/1000 inch) is "pt"

    An abbreviation for parsec (~ 30856802485074000 meters) is "pc"

    An abbreviation for pint (1/8 gallon) is "pt"

    An abbreviation (i guess, properly, an alternate name) for millimetres of mercury (~ 133.3223684 pascals) is "torr"

    You may think this is unfortunate, but that doesn't make any of those statements untrue, or any more "wrong" than any of the others.

     

    No matter how many people use it, it will always be wrong. Units are not defined by popularity: that way leads to chaos and madness, as any country more than a millennium old can attest. Standard names for units is not just a good idea, it's the law.

    XpY is the standard abbreviation for writing sizes measured in picas, where X is picas and Y is points, but most people just write "8 points" in software. Pica measurements are only typically used in serious typesetting, not the desktop stuff.

    Anyway, chaos and madness notwithstanding, when you know what quantity you're talking about (and, distance on a page is a VERY different quantity than thickness of a piece of paper, even if it has the same dimensionality - for the same reason that fuel efficiency isn't measured in square millimetres*), it's OK if units used for two different purposes have the same name, or even the same symbol.

    We use ° for temperature and angle, ″ for distance and time (and angle), has this ever caused any confusion?

    *(1 l/100km = 0.01 mm^2) 



  • @Thief^ said:

    EDIT: IIRC VB.net confuses the issue by working in typographic points (1/1000th inch) instead of the "cardboard points" that the rest of windows uses (1/72nd inch).

    VB.net works in points (typographic, 1/72 inch) - VB prior to .net, used "twips" (1/20 point) 



  • @Random832 said:

    An abbreviation for point (1/72 inch) is "pt"

    You just made that up. Units are not things that are just made up.

     

    We use ° for temperature and angle

    We also use 'a' for both temperature and angle. That doesn't mean a damn thing.

    The degree sign alone is a measurement of angle. Always. A measurement of temperature uses the degree sign PLUS a letter (or on some scales, just a letter).

    ″ for distance and time (and angle), has this ever caused any confusion?

    Hell yes. That's why it's not an approved unit. Distance and time are denoted with letters, SI is very clear on this: the primes are for angles only.



  • @asuffield said:

    @Random832 said:
    An abbreviation for point (1/72 inch) is "pt"

    You just made that up. Units are not things that are just made up.

    I didn't make it up. Lots of computer programs, ones that exist (and have for quite some time), use it. CSS uses it. One might even go so far as to call it an industry standard. 

    We use ° for temperature and angle

    We also use 'a' for both temperature and angle. That doesn't mean a damn thing.

    The degree sign alone is a measurement of angle. Always. A measurement of temperature uses the degree sign PLUS a letter (or on some scales, just a letter).

    Once again, actual usage disagrees with your made up rules. 

    ″ for distance and time (and angle), has this ever caused any confusion?

    Hell yes. That's why it's not an approved unit. Distance and time are denoted with letters, SI is very clear on this: the primes are for angles only.

    The SI isn't the only game in town, and has absolutely sod all to do with any unit called a degree, any unit (apart from the [time] second) that anyone has ever thought to denote with ″, and any unit called a "point".

    The status quo is what it is. That you don't like it doesn't make it wrong. Or illegal.



  • Here knock yourselves out: http://www.unece.org/cefact/recommendations/rec_index.htm And your looking for rec. 20 which are the Codes for Units of Measure Used in International Trade.
    I'm unsure if it applies to the rest of the world but i think it does, at least for business systems. 

    Also, i'm not sure about Kelvin, but celsius is 'degrees celsius' and written as °C. And i've never ever seen people write it just as "C" or just as "°", Although people might say, "The water is 100 degrees"

     



  • @Random832 said:

    @asuffield said:

    Hell yes. That's why it's not an approved unit. Distance and time are denoted with letters, SI is very clear on this: the primes are for angles only.

    The SI isn't the only game in town, and has absolutely sod all to do with any unit called a degree, any unit (apart from the [time] second) that anyone has ever thought to denote with ″, and any unit called a “point”.

    The status quo is what it is. That you don’t like it doesn’t make it wrong. Or illegal.

    P.S. This actually leaves me to wonder what on earth the SI could have to say about the use of primes for angles, being as the only SI unit for angular measure is in fact the radian.


  • Discourse touched me in a no-no place

    @stratos said:

    Also, i'm not sure about Kelvin,

    Erm - the answer is don't. People have flame wars about this (hey, lets start another...)

     
    It's 0 degrees Celsius, 32 degrees f<font size="-1">ahrenheit</font>, and 273.15 Kelvin. (And 491.67 degrees Rankine, since you didn't ask...)



  • @PJH said:

    It's 0 degrees Celsius, 32 degrees f<font size="-1">ahrenheit</font>, and 273.15 Kelvin.

    Why?

    blinks large eyes innocently

     


  • Discourse touched me in a no-no place

    @dhromed said:

    @PJH said:

    It's 0 degrees Celsius, 32 degrees f<font size="-1">ahrenheit</font>, and 273.15 Kelvin.

    Why?

    blinks large eyes innocently

     

    Because. Otherwise flame wars result when people talk about {snipped}

     

    I notice you snipped my Rankine bit - is that verboten here? 



  • @PJH said:

    @stratos said:

    Also, i'm not sure about Kelvin,

    Erm - the answer is don't. People have flame wars about this (hey, lets start another...)

     
    It's 0 degrees Celsius, 32 degrees f<font size="-1">ahrenheit</font>, and 273.15 Kelvin. (And 491.67 degrees Rankine, since you didn't ask...)

    I always found it weird there where so many ways to define a temperature.
    I mean it's like saying, "hey i invented a new counting system, and now we start at 200, and everything below that should be considered low"

    I understand some of these probably got invented/defined around the same time, but come on 4 different ways to define the same thing, in the same scale.


  • Discourse touched me in a no-no place

    @stratos said:

    I mean it's like saying, "hey i invented a new counting system,[...]"  but come on 4 different ways to define the same thing, in the same scale.

    {apologies for an OOC quote}

     Like decimal, only in binary, trinary, octal and  hexadecimal?

    Sorry - that's 5.

    As you were....
     



  • @PJH said:

    @stratos said:

    I mean it's like saying, "hey i invented a new counting system,[...]"  but come on 4 different ways to define the same thing, in the same scale.

    {apologies for an OOC quote}

     Like decimal, only in binary, trinary, octal and  hexadecimal?

    Sorry - that's 5.

    As you were....
     

     

    call me biased, but for some reason different bases seem sane, while diffrent temperature notations don't


     



  • @Random832 said:

    @Thief^ said:

    EDIT: IIRC VB.net confuses the issue by working in typographic points (1/1000th inch) instead of the "cardboard points" that the rest of windows uses (1/72nd inch).

    VB.net works in points (typographic, 1/72 inch) - VB prior to .net, used "twips" (1/20 point) 

    If you want to keep your sanity intact, you won't attempt to find out what units Office Open XML, the document format Microsoft is currently trying to push through ISO, uses. (Hint: it depends. I have to admit, they've done a good job of coming up with lots of named units based on fractions of an inch.)



  • @makomk said:

    @Random832 said:
    @Thief^ said:

    EDIT: IIRC VB.net confuses the issue by working in typographic points (1/1000th inch) instead of the "cardboard points" that the rest of windows uses (1/72nd inch).

    VB.net works in points (typographic, 1/72 inch) - VB prior to .net, used "twips" (1/20 point) 

    If you want to keep your sanity intact, you won't attempt to find out what units Office Open XML, the document format Microsoft is currently trying to push through ISO, uses. (Hint: it depends. I have to admit, they've done a good job of coming up with lots of named units based on fractions of an inch.)

    Found some info:

    http://www.grokdoc.net/index.php/EOOXML_objections#Fabricates_units_of_measurement

    EMU, "English Metric Units" = 1/91440 inch = 1/36000 cm = 1/1270 pt

    is probably what you're referring to - at least it seems relatively obvious what the purpose of this unit is. It can express sixteenths of an inch, halves of a point, hundredths of a millimeter, oddly though not twips, all as a whole number, and it can express smaller fractions (of numbers whose only factor is 2 or 5, at least) of either without risking infinite repeating (what's 1/2.54?). The twip is not fabricated, or, at least, not fabricated recently.

    On the other hand "In contrast, for example, the W3C SVG and W3C CSS standards both
    consistently use a single notation—decimal percentages followed by
    the "%" symbol—s described in section 7.10 of the W3C SVG 1.1
    specification and section 4.3.3 of the CSS 2.1 specification." seems spurious. CSS, at least, uses other notations inconsistently - you use 0.50, not 50% for opacity, for example, and a decimal (and hexadecimal) number that is 1/255th [not 1/256th, even] of 100%



  • @PJH said:

    @stratos said:

    I mean it's
    like saying, "hey i invented a new counting system,[...]"  but come on
    4 different ways to define the same thing, in the same scale.

    {apologies for an OOC quote}

     Like decimal, only in binary, trinary, octal and hexadecimal?

    Sorry - that's 5.

    As you were....

    if 0 hex were 42 decimal, and 0 decimal were -2A hex, you’d have a point.


  • Discourse touched me in a no-no place

    @Random832 said:

    @PJH said:
    @stratos said:

    I mean it's like saying, "hey i invented a new counting system,[...]"  but come on 4 different ways to define the same thing, in the same scale.

    {apologies for an OOC quote}

     Like decimal, only in binary, trinary, octal and hexadecimal?

    Sorry - that's 5.

    As you were....

    if 0 hex were 42 decimal, and 0 decimal were -2A hex, you’d have a point.

    You quoted, but appeared to have missed, my apology for a deliberate QOOC.

    I deliberately omitted the shifting of the 0 value in order to make my post.

    There - joke explained, and ruined. Happy now?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.