; docformat = 'rst' ;+ ; Batch file containing all the code intended to be typed at the command line ; from the "Objects" chapter. ;- monitors = obj_new('IDLsysMonitorInfo') help, monitors print, monitors->getNumberOfMonitors() print, monitors->getResolutions() print, monitors->getRectangles() monitors->getProperty, display_name=name help, name obj_destroy, monitors ; Concepts ; Writing a class window, 0 plot, findgen(11) print, convert_coord(0.5, 0.5, /normal, /to_data) window, 1 plot, findgen(11) / 10., findgen(11) / 10. wset, 0 print, convert_coord(0.5, 0.5, /normal, /to_data) window, 0 plot, findgen(11) vars = obj_new('MGdgVars') vars->save print, convert_coord(0.5, 0.5, /normal, /to_data) window, 1 plot, findgen(11) / 10., findgen(11) / 10. wset, 0 vars->restore print, convert_coord(0.5, 0.5, /normal, /to_data) obj_destroy, vars prefs = obj_new('mgffprefs', author_name='mgalloy', app_name='idlfordevelopers') prefs->set, 'name', 'Michael' obj_destroy, prefs prefs = obj_new('mgffprefs', author_name='mgalloy', app_name='idlfordevelopers') name = prefs->get('name', found=found) print, name ; Inheritance c1 = obj_new('MG_Container', name='c1') c2 = obj_new('MG_Container', name='c2') c1->add, c2 c3 = obj_new('MG_Container', name='c3') c1->add, c3 c4 = obj_new('MG_Container', name='c4') c2->add, c4 c5 = obj_new('MG_Container', name='c5') c2->add, c5 checkC4 = c1->getByName('c2/c4') checkC4->getProperty, name=checkC4Name help, c4, checkc4 ; Operator overloading s1 = mg_string('IDL is fun!') help, s1 print, s1 s2 = mg_string('The temperature in %s was %d degrees') print, s2 # { name: 'Boulder', temp: 75 } print, s2.length print, s2[0:6] print, s2[0:*:2] print, s1 + ' -- ' + s2 # { name: 'Boulder', temp: 75 } ; Tricks and techniques ; For those familiar with other object-oriented languages