CIS 111 FAQ

  1. What if I missed my week 1 lab? If possible, go to another lab this week; tell the GTF that you're not in the lab, and you can watch from the sidelines.

    Also, the GTF will hold two extra sessions in the lab during week 2 devoted to the same material covered in the week 1 lab. The times of these lab sessions will be announced in class and posted to the 111 email list so please make sure that DuckWeb knows your primary email account.

  2. How do I change labs?

    We are handling this informally. You do not have to use the DuckCall "exchange section" command (XS, 97) after it starts costing you $$ to do so. Here's what to do:

    Go to the lab you want and ask the GTF if there's room for you. If your GTF says Yes, make sure that s/he has your name removed from your original lab and added to the new one. If the GTF says No, you will have to attend a different lab.

  3. Should I bring my book to class each day? A good idea, since your instructor will frequently be covering examples taken from the book.

  4. Gladstone uses the Delete key to erase characters, but I prefer to use the Backspace key. How do I set it up?

  5. How can I download a file from the 111 datafiles directory and print it at home (and avoid the cost of printing charges in B26 Kla)?

    Example:
    Using a browser on your home computer open a folder, then click-right on the name of the file you wish to download and choose Save Link As.. to save the file to your hard drive. The file may then be opened in TextPad (or any other text editor) and printed.

  6. How can I get that cool prompt you have? How can I define useful aliases?

    Using Emacs or Pico on gladstone, copy and paste these into your ~/.cshrc file:

    #display current directory in prompt
    set prompt = "[$cwd]% "
    #this is also required for the custom prompt
    alias cd 'chdir \!* && set prompt = "[$cwd]% ";ls'
    #this alias is optional, sets g = cd
    alias g 'chdir \!* && set prompt = "[$cwd]% ";ls'

    alias j jobs
    alias c clear # clear the display
    alias cw 'chmod 664' # make an .html file web accessible
    alias cx 'chmod 755' # set the standard mode for a directory
    alias cp cp -i # Ask before overwriting a file
    alias ed emacs
    alias h history
    alias k logout # kill
    alias ls ls -F # Marks dirs w/, links w/@, executables w/*
    alias ll ls -l # long listing
    alias ld ls -dl # show status of directory not contents
    alias lsx "ls -CR | more" # shows all files in all directories
    alias q fg # resume most recently suspended job
    alias rme "rm *~;rm #*#; ls" # remove all emacs backup files
    alias rmb "rm *.bak; ls" # remove all textpad backup files
    alias 1 %1 #resume job id = 1
    alias 2 %2 #resume job id = 2
    alias 3 %3 #resume job id = 3

  7. May I take CIS 111 P/N? That depends on your reason for taking 111. 111 does not have to be taken for a grade to satisfy the B. Sci. math and computing requirement. Certain programs that require CIS 111, however, require that you take it graded. Check with your department.

  8. Working with long strings in a JavaScript. If you type in a loooooong string using TextPad, the Word-Wrap button on the main toolbar can be used to wrap the long string to the start of the next line. However, when you save this file, a hard line break will be saved at the end of each wrapped line, and this breaks the string literal into two, which causes an error in JavaScript.

    To even see the error, you will have to open the JavaScript console.

    You can configure TextPad to save long lines without hard line breaks: Choose Configure Preferences.. for document class HTML to save a file with no line breaks in word-wrapped long lines. By default, TextPad will save the file with hard breaks (i.e., a carriage return) in word-wrapped long lines.

    A simpler alternative is to manually "escape" your own carriage returns in long strings. Here's a clear example of the concept, from Indispensable JavaScript Tutorials, www.jennifermadden.com:

    Escaping Carriage Returns. When working with long strings in your source code, you may be tempted to break the string up into multiple lines to make it more readable. While this sounds good, placing a carriage return in the middle of quoted text string will cause a script error - which for IE browsers is "Unterminated string constant". This is because the JavaScript interpreter sees carriage returns as the end of a statement - you may as well have placed a semi colon there.

    Although the next lesson covers much more efficient ways to break up a long string, I'll quickly explain how the escape character can be used to do the same thing. Place a single string on multiple lines using only one set of quotes for the entire string. Anywhere you want to break the string, place the escape character ( \ ) at the end of the line, then a carriage return.

    'hello world.\
    my name is Jenn\
    ifer.'

    This carriage-retun-escaping technique which simply breaks up a string in source code is not often used because it does not provide a way to concatenate a string variable into the mix. But hey, somebody out there just might like to use it!

    JavaScript Strings: Nesting Quotes And The Escape Character

    Many times you will work with strings which contain quotes. Since the JavaScript interpreter reads the first quote it encounters as the beginning of the string, and reads the very next quote it encounters as the end of the string, we need a way to signify that a quote is part of a string and not the end of it.

    There are two ways to accomplish this goal: nesting opposite quotes and using a special character called the escape character.

    Nesting Opposite Quotes

    String values can be surrounded by either single quotes or double quotes. Except in the case of event handlers which always surround their values in double quotes, which type of quote you use is entirely up to you.

    Which type of quote you use to surround your nested string is determined by the type of quote surrounding its containing string. A nested string is surrounded by the oppisite kind of quote which surrounds its containing string. I call this "quote swapping". In other words, if my outer string is contained by double quotes, my inner string must be contained by single quotes, and vice versa.

    Nest single and double quotes as follows:

    var beasty = "He said 'howdy', I said 'hi'." // nesting single quotes within double quotes

    var boys = 'He said "howdy", I said "hi".' // nesting double quotes within single quotes

    <a href="javascript:alert(boys)">Show me the string</a>

    The Escape Character

    It is legal to surround a nested string with the same type of quote as is surrounding its containing string as long as the escape character ( \ ) precedes the nested quote. The escape character tells the JavaScript interpreter that the quote is part of the string, not the end of the string.

    var beasty = "He said \"howdy\", I said \"hi\"." // nesting double quotes within double quotes

    var boys = 'He said \'howdy\', I said \'hi\'.' // nesting single quotes within single quotes

    <a href="javascript:alert(beasty)">Show me the string</a>

    Some scripters, including myself, prefer to use the escape character rather than quote swapping to avoid mistakes so easily made when nesting both kinds of quotes. Others always use single quotes (except in the case of event handlers) to contain their nested quotes. The reason is that very often your JavaScript strings are HTML - which requires its attributes to be quoted. This allows the printing of the HTML to be "natural" - as it would be written in a static document, with double quotes surrounding attribute values.

            document.write('onclick="alert(\"Hello, World\")"')