home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / pc / Open Me for REALbasic 3 / REALbasic 3.2 / Goodies / 3rd Party Demos / 3rd Party Plugins / Misc / StrToLong Plugin w_source / StrToLong.cpp < prev    next >
Encoding:
Text File  |  1998-05-25  |  920 b   |  39 lines

  1. //StrToLong by Jason Toffaletti email: catalyst@kagi.com
  2. //A simple realbasic plugin for learning by example.
  3. //Thanks to Ecky, Nick, Kevin, James, and Einhuger for help with learning C.
  4. //http://catalyst.hypermart.net for other software by Jason and Ryan.
  5.  
  6. #include "rb_plugin.h"
  7. #include <math.h> //Also need to include MathLib in the project.
  8.  
  9. void PluginEntry(void);
  10.  
  11. static double StrToLong(REALstring str)
  12. {
  13.     int x=3;
  14.     double temp=0;
  15.     while (x != -1) {
  16.         temp = temp + ( pow(256,(4-(x+1))) * REALCString(str)[x] ); //pow is defined in math.h
  17.         x--;
  18.     }
  19.     return temp;
  20. }
  21.  
  22. //Everything after this is to register the function with REALBasic.
  23.  
  24. REALexport pluginExports[] = {
  25.     { nil, StrToLong}
  26. };
  27.  
  28. short pluginExportCode = sizeof(pluginExports) / sizeof(REALexport);
  29.  
  30. REALmethodDefinition StrToLongdefn = {
  31.     0,
  32.     "StrToLong(thestr as string) as double"
  33. };
  34.  
  35. void PluginEntry(void)
  36. {
  37.     REALRegisterMethod(&StrToLongdefn);
  38. }
  39.