Resources can be set in three ways:
First you load specific resources and the values to be assigned to those resources into a resource list (rlist in this case). Then you issue a call to create an object with the resource list as an argument.
Examples:
Fortran: call nhlfrlsetfloat(rlist,'vpXF',.2,ierr) call nhlfrlsetfloat(rlist,'vpYF',.8,ierr) call nhlfrlsetfloat(rlist,'vpWidthF',.6,ierr) call nhlfrlsetfloat(rlist,'vpHeightF',.6,ierr) call nhlfcreate(pid,'Titles',nhlftitleclass,wid,rlist,ierr) C: NhlRLSetFloat(rlist,NhlNvpXF,.2); NhlRLSetFloat(rlist,NhlNvpYF,.8); NhlRLSetFloat(rlist,NhlNvpWidthF,.6); NhlRLSetFloat(rlist,NhlNvpHeightF,.6); NhlCreate(&pid,"Titles",NhltitleClass,wid,rlist);
Note that in C, the full resource name, including the NhlN prefix, is given. The NhlN prefix is a C macro for the string. If you wanted, you could use the short name in double quotes. However, the advantage of using the NhlN define is that the compiler will catch misspellings. In Fortran, the short name is enclosed in single quotes.
In this example, we are setting the upper left corner of a device viewport (vpXF,vpYF), then specifying the width and height of the viewport, vpWidthF and vpHeightF.
Again you load specific resources and the values to be assigned to those resources into a resource list (rlist in this case). Then you issue a call to set the resource values with rlist as an argument.
Examples:
Fortran: call nhlfrlsetfloat(rlist,'vpXF',.2,ierr) call nhlfrlsetfloat(rlist,'vpYF',.8,ierr) call nhlfrlsetfloat(rlist,'vpWidthF',.6,ierr) call nhlfrlsetfloat(rlist,'vpHeightF',.6,ierr) call NhlFSetValues(pid,rlist,ierr) C: NhlRLSetFloat(rlist,NhlNvpXF,.2); NhlRLSetFloat(rlist,NhlNvpYF,.8); NhlRLSetFloat(rlist,NhlNvpWidthF,.6); NhlRLSetFloat(rlist,NhlNvpHeightF,.6); NhlSetValues(pid,rlist);
The third method is to set the resource value in a resource file. This is the recommended method for most cases because resource files are read by the program as data. Thus, you can change resource values and re-execute the program module without having to recompile, link, and load. If you change a resource value through the functional API, then you must recompile, etc. Clearly the resource file approach is more efficient in user and machine time.
The disadvantage of using resource files is that errors, such as misspellings, are not reported, and if a resource value changes during execution, resource files are not adequate.
NG4.1 Home, Index, Examples, Glossary, Feedback, UG Contents, UG WhereAmI?