India seo web development website designer freelance

Calling a C function from JavaScript

After you understand how C-level extensibility works in and its dependency on certain data types and functions, it's useful to know how to build a library and call a function.

This example requires four files, which are included in the Extending/c_files folder inside the application folder:

To build the DLL in Windows:
  1. In Microsoft Visual C++, choose File > Open Workspace and select Sample.mak.
  2. Choose Build > Rebuild All.
  3. When the build operation finishes, a file called Sample.dll appears in the folder that contains Sample.mak (or one of its subfolders).

To build the shared library on the Macintosh:
  1. Open Sample.proj in Metrowerks CodeWarrior.
  2. Build the project to generate a CFM Library.
  3. When the build operation finishes, a file called Sample appears in the folder that contains Sample.proj (or in one of its subfolders).

To call the computeSum() function from the Insert Horizontal Rule object:
  1. Create a folder called JSExtensions in the Configuration folder within the application folder.
  2. Copy Sample.dll (Windows) or Sample (Macintosh) to the JSExtensions folder.
  3. In a text editor, open the file called horizontal_rule.htm in the Configuration/Objects/Common folder.
  4. Add the line alert(Sample.computeSum(2,2)); to the objectTag() function so that it appears as shown in the following example:
  5. function objectTag() { // Return the html tag that should be inserted alert(Sample.computeSum(2,2)); return "<HR>"; }
  6. Save the file and restart .
To execute the computeSum() function:

Choose Insert > Horizontal Rule.

A dialog box that contains the number 4 (the result of computing the sum of 2 plus 2) appears.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

India web developer website development India