Advertisement
Segfault1

For loop

Apr 13th, 2023 (edited)
1,952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Iterate over each object in the list using a for loop
  2. var i;
  3. for (i = 0; i < ds_list_size(objList); i++)
  4. {
  5.     // Get the object at the current index in the list
  6.     var obj = ds_list_find_value(objList, i);
  7.  
  8.     // Code to be executed for each object in the list
  9.  
  10.     // Perform an action on the current object
  11.     obj.action();
  12. }
  13.  
  14.  
  15. FOR ARRAY
  16.  
  17. // Create an array and add some objects to it
  18. var objArray;
  19. objArray[0] = obj_Object1;
  20. objArray[1] = obj_Object2;
  21. objArray[2] = obj_Object3;
  22. objArray[3] = obj_Object4;
  23.  
  24. // Get the length of the array
  25. var arrayLength = array_length_1d(objArray);
  26.  
  27. // Iterate over each object in the array using a for loop
  28. var i;
  29. for (i = 0; i < arrayLength; i++)
  30. {
  31.     // Get the object at the current index in the array
  32.     var obj = objArray[i];
  33.  
  34.     // Code to be executed for each object in the array
  35.  
  36.     // Perform an action on the current object
  37.     obj.action();
  38. }
  39.  
  40.  
  41.  
  42. NULL VERIFICATION
  43.  
  44.  
  45. if (obj != null)
  46.     {
  47.         // Code to be executed for non-null objects
  48.  
  49.         // Perform an action on the current object
  50.         obj.action();
  51.     }
  52.     else
  53.     {
  54.         break
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement