PRODUCT






Home









Free Download








Installation Instructions





FAQ





FAQ








Ask A Question





LEARN SCRIPTING





Overview








Lesson 1








2


3


4


5








Exam





SAMPLE SCRIPTS





Computer








Internet








Administrators








Developers








Data








Miscellaneous





HELP / DOCUMENTATION





Commands








Automated Internet








Automated Editors








Sample Scripts








Precompiled Functions








System Features






biterScripting (TM) - Exam 1

Please write answers to all questions in the boxes provided.



QUESTION 1
We wrote the script squares.txt in Lesson 2. It printed squares of numbers from 0 through 30. That script is listed below. (I have modified it slightly for the purposes of this question.)


##################################################################
# SCRIPT squares.txt
##################################################################
# The script prints squares of numbers from 0 through 30.
##################################################################
var integer number, power
while ($number <= 30) 
do 
    set $power = $number ** 2
    echo $power
    set $number = $number + 1 
done 



Create a new script powers.txt based on the above script. The power.txt script will accept two input arguments - max and n. Both input arguments are integers. The script will loop through numbers from 0 to $max, and print the number raised to power of $n. For example, if $max is 100 and $n is 3, it will print cubes of all numbers from 0 through 100.

Answer 1




QUESTION 2
What are the two modes of stream redirection ? What is the difference between them ?

Answer 2




QUESTION 3
Write a script that will accept a text file as an input argument (FVA - Forward Variable Assignment). The script will generate an output that will list each line (including empty lines) in the file along with line numbers. For example, the file C:/LearningScripting/Lesson5/Sample5.txt has the following contents.

Alejandro Genovicci, Rome, Italy

Jet Huang, Shanghai, China
Pam Jones, dallas, USA
Arvind Kumar, Bangalore, India
William Keane, Perth, Australia



The script should list a line number, followed by a tab, following by the actual line, for each line (including empty lines) in the input text file. Line numbers should begin with 1. For the above Sample5.txt file, the output should look like the following.

1	Alejandro Genovicci, Rome, Italy
2	
3	Jet Huang, Shanghai, China
etc.


Call this script ListFile.txt. (Hint: Use the lex command with -e option.)

Answer 3




QUESTION 4 (This question is moderately hard.)
In the above ListFile.txt script, if the -e option were not included in the lex command, the script would go into an infinite loop (the script will never terminate). Why ?

Answer 4




QUESTION 5 (This question is significantly hard.)
See the following script. Since there are no comments, it is hard to tell what the script is doing.
Try to understand the script. What does the script do ?
Add generous comments to the script so that a reader of the script will understand what the script is doing, and how it is doing it.


var int i
var str pl
set $i=2

while ($i<1000)
do
    if ($pl == "")
    do
        echo $i
        echo $i "\n" >> $pl
    done
    else
    do
        var str pl2
        set $pl2 = $pl
        var int d
        set $d = 0
        while ( ($d==0) AND ($pl2 <> "") )
        do
            var str ps
            lex "1" $pl2 > $ps
            var int p
            set $p = makeint(str($ps))
            if ( (($i/$p)*$p) == $i)
                set $d = 1
            endif
        done
        if ($d == 0)
        do
            echo $i
            echo $i "\n" >> $pl
        done
        endif
    done
    endif
    set $i = $i + 1    
done






Answer 5




Want to see the answers to the questions in this exam ? We can email them to you. But, you must send us your answers first. Fill in the following information, then press the Submit button.



Name
Email

2008-2014, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com. Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.