Advertisement
idsystems

CPP_RAD_Ejercicio49

Jun 21st, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. /* ej49_Arrays
  2. Ejemplo de Arreglos asociativos */
  3. #include <radc++.h>
  4.  
  5. Form         form1("Arrays Asociativos - RAD C++ Ejemplo");
  6. Label       label1("EMPLEADO BIO\n\n",-1,50,50,150,200,form1);
  7. SunkLine    line1(210,50,2,200,form1);
  8. Label       label2("EMPLEADO INFO\n\n",-1,250,50,100,200,form1);
  9.  
  10. //create an associative array to hold  string values
  11. createAssocArray(String, bio_data);
  12.  
  13. //create an associative array to hold  integers
  14. createAssocArray(int,   extra_info);
  15.  
  16. //NOTE: function createAssocArray accepts two arguments, where 1st is type of array elements,
  17. //      and second is the name of variable.
  18.  
  19. rad_main()
  20.  
  21.      //add some values to array of strings 'bio_data'
  22.      bio_data["nombre"]     = "Ali Imran";
  23.      bio_data["titulo"]     = "Programmer";
  24.      bio_data["hobbies"]    = "Programming";
  25.      bio_data["NIC#"]       = "PM-8500881";
  26.      bio_data["ciudad"]     = "Islamabad";
  27.      bio_data["pais"]   = "Pakistan";
  28.      
  29.      
  30.      //add some values to array of integers 'exta_info'
  31.      extra_info["edad"]     = 30;
  32.      extra_info["estatura"] = 6.1;
  33.      extra_info["salario"]  = 30000;
  34.      extra_info["grado"]    = 19;
  35.      
  36.      
  37.      for(int i=0; i<bio_data.length; i++) {
  38.         label1.caption = label1.caption + "\n" + bio_data.indexName(i) +"\t" + bio_data[i];
  39.      }
  40.      
  41.      
  42.      for(int i=0; i<extra_info.length; i++) {
  43.         label2.caption = label2.caption + "\n" + extra_info.indexName(i) +"\t" + str(extra_info[i]);
  44.      }    
  45.  
  46.  
  47.      //to accesss in field separately use
  48.      //String test = bio_data["country"];
  49.      //and for integer as we have in above example
  50.      //int test = extra_info["salary"];
  51.  
  52. rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement