Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.94 KB | None | 0 0
  1. let type;
  2. let arr;
  3. let a0;let a1;let a2;let a3;let a4;let a5;let a6;let a7;let a8;let a9;
  4.  
  5. function Arr_Init(n,v){
  6.     let a;
  7.     alternative(type)
  8.     case('V'){ a=""; a0=v; }
  9.     case('v'){ a=""; ascent(i in 0..n){ SetAVar(i,v); } }
  10.     case('n'){ a=[]; loop(n){a=a~[v];} }
  11.     case('o'){  
  12.         a=""; ascent(i in 0..n){ Obj_SetValue(a,itoa(i),v); }
  13.         Obj_SetValue(a,"length",n);
  14.     }
  15.     case('c'){  
  16.         a="arr"~itoa(GetNextHash);  ascent(i in 0..n){ SetCommonData(a~itoa(i),v); }
  17.         SetCommonData(a~"length",n);
  18.     }
  19.     case('a'){
  20.         a="arr"~itoa(GetNextHash);
  21.         if(!IsCommonDataAreaExists(a)){ CreateCommonDataArea(a); } else { ClearAreaCommonData(a); }
  22.         ascent(i in 0..n){ SetAreaCommonData(a,itoa(i),v); }
  23.         SetAreaCommonData(a,"length",n);
  24.     }
  25.     return a;
  26. }
  27.  
  28. function Arr_Set(a,i,v){
  29.     alternative(type)
  30.     case('V'){ a0=v; }
  31.     case('v'){ SetAVar(i,v); }
  32.     case('n'){ arr[i] = v; } //cheating a bit
  33.     case('o'){ Obj_SetValue(a,itoa(i),v); }
  34.     case('c'){ SetCommonData(a~itoa(i),v); }
  35.     case('a'){ SetAreaCommonData(a,itoa(i),v); }
  36. }
  37. function Arr_Get(a,i){
  38.     alternative(type)
  39.     case('V'){ return a0; }
  40.     case('v'){ return GetAVar(i); }
  41.     case('n'){ return a[i]; }
  42.     case('o'){ return Obj_GetValue(a,itoa(i)); }
  43.     case('c'){ return GetCommonData(a~itoa(i),NULL); }
  44.     case('a'){ return GetAreaCommonData(a,itoa(i),NULL); }
  45. }
  46.  
  47. function Arr_Length(a){
  48.     alternative(type)
  49.     case('n'){ return length(a); }
  50.     case('o'){ return Obj_GetValue(a,"length"); }
  51.     case('c'){ return GetCommonData(a~"length",0); }
  52.     case('a'){ return GetAreaCommonData(a,"length",0); }
  53. }
  54.  
  55.  
  56.  
  57. function GetAVar(i){
  58.     alternative(i)
  59.     case(0){return a0;}case(1){return a1;}case(2){return a2;}case(3){return a3;}case(4){return a4;}case(5){return a5;}case(6){return a6;}case(7){return a7;}case(8){return a8;}case(9){return a9;}
  60. }
  61. function SetAVar(i,v){
  62.     alternative(i)
  63.     case(0){a0=v;}case(1){a1=v;}case(2){a2=v;}case(3){a3=v;}case(4){a4=v;}case(5){a5=v;}case(6){a6=v;}case(7){a7=v;}case(8){a8=v;}case(9){a9=v;}
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement