Star Command Programming

No matter how many features are built into a program, there always appear to be new applications that demand some capability not included. A command language allows you to extend the scope of a program by combining built-in commands with additional routines to create new commands. OSLO Light contains a command language known as SCP, and OSLO PRO and SIX contain a command language known as CCL. The difference between the two is that SCP is an interpreted language that uses predeclared variables to obtain enhanced performance, while CCL is a compiled language that allows full declaration and scoping of variables. Both languages have a syntax compatible with the C programming language. CCL allows you to make substantial extensions to OSLO SIX, using local and global variables, two-dimensional arrays, and callback programming. The OSLO reference manual contains a full description of CCL.

Both SCP and CCL are in fact command languages that allow the user to build new commands using all of OSLO’s internal commands. They provide full data communication with results computed by the internal commands, as well as a support library of over 100 subroutines for graphics, file and I/O access, window management, and math. To illustrate a typical application of SCP, the following exercise will show how to scale the constructional data for a system to a different focal length. Since OSLO already has a built-in command that does this, you can check your results.

SCP programs are called "star commands" because the first character of the command name must be an asterisk. Star commands are prepared using the OSLO text editor (or any other text editor) and are saved in the directory public\scp directory. Star commands can either be saved in a file having the name of the command and a tag ".scp", or saved in the default.scp file.

  • 1. Click Window >> Editor>> Open. Click File >> Open (in the text editor window). The file dialog box will appear. Change to the private/scp directory as shown below, and open the file default.scp.
  • In the editor, leave one blank line after the last command, then enter the following:

    *scfl
    for (i=1;i<ims;i++)
    printf("Radius %d is %f\n", i, rd[i]);

  • 2. Save the file, click in the main window command line, and enter the command *scfl. You should see something like (assuming that the demotrip lens is opened).
  • Radius 1 is 21.250000
    Radius 2 is -158.650000
    Radius 3 is -20.250000
    Radius 4 is 19.300000
    Radius 5 is 141.250000
    Radius 6 is -17.285000

  • 3. The above command shows that you can retrieve the lens radii using the notation rd[i], and the image surface number by ims. Next, go back to the editor, and add the following lines and comment out the lines that you had before. (Note that "//" indicates that all remaining information on that line is a comment, so it is not necessary to type it.)
  • *scfl
    stp outp off; // Turns off output printing
    sbr; // Clears spreadsheet buffer
    pxc; // Computes paraxial constants
    f=a1; // Gets efl from spreadsheet buffer
    printf("efl %.4f\n", f); // Prints SCP output
    // for (i=1;i<ims;i++)
    // printf("Radius %d is %f\n", I, rd[i]);
    stp outp on; // Restores normal output

  • 4. Save the file, switch back to the main window, and again enter the command *scfl. Now you should see the following:

    efl 50.0005

  • The new command shows how you can use OSLO to compute a value, and transmit it to your star command using the speadsheet buffer.

  • 5. Finally, go back to the editor and finish the whole *scfl command. The final command adds the input command and the get_glass_name function.
  • *scfl
    stp outp off;
    sbr;
    pxc;
    f=a1;
    printf("\n*scfl\n");
    printf("Current focal length is %.4f\n", f);
    input(&e,"Enter desired focal length:");
    printf("Desired focal length is %.4f\n", e);
    printf("New system data...\n\n");
    printf("SRF RADIUS THICKNESS GLASS\n");
    s=e/f;
    for (i=1;i<ims;i++)
    {
    get_glass_name(i);
    printf("%3d %13.6f %13.6f %s\n", i, s*rd[i], s*th[i], glass_name);
    }
    stp outp on;

  • 6. Save the file, switch back to the main window, and again enter the command *scfl. You will be prompted for the desired focal length. Assuming that you enter 40, the final output is:
  • *scfl
    Current focal length is 50.0002
    Desired focal length is 40.0000
    New system data...
    SRF RADIUS THICKNESS GLASS
    1 16.999934 1.599994 SK16
    2 -126.919505 4.799981 AIR
    3 -16.199937 0.799997 F4
    4 15.439940 4.799981 AIR
    5 112.999559 1.599994 SK16
    6 -13.827946 34.359866 AIR

    The exercise presented here shows a typical technique for developing star commands, i.e. interactively, piece by piece. Several other star commands are included on the disc in the public\scp directory. You can examine them and try them out to learn more about SCP. The final step is to add the new command to the menu.

  • 7. In the editor, change your directory to the public\ccl directory and open the file a_menu.ccl.

    8. Scroll through the file until you find the section called menu User. This is where user modifications to the menu should normally be placed. The details of the items under this heading will depend on the version of OSLO that you are using. At the bottom of the list, add another line as shown below. Then Click File >> Save to save the file.

  • menu User
    {
    "A,Analysis" = $User_analysis,
    "-S,Set apertures..." = "*apset",
    "V,Vignetting analysis" = "*rimray 1",
    "-I,Image analysis..." = "*image",
    "n,Interferogram..." = "*interf",
    "-h,Ghost analysis..." = "*ghosts",
    "u,Narcissus analysis..." = "*nars",
    "-G,Glass manager..." = "*glassman",
    "-M,My Scale " = "*scfl",

    }

     

    You can now execute the command by clicking User >> My Scale. After you have verified that this works, restore the original menu.

    | Previous Page | Chapter Summary | Table of Contents


    Copyright © 1997 Sinclair Optics Inc. All rights reserved.
    Page last updated 19970601