inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jun 29, 2015 23:45:34 GMT -8
Tim CamaraWhen using something like key.push() , you can have a callback error function in case something went wrong, but is there a way to know WHICH error it encountered? is it possible to add a parameter into the function definition that will let you do different things based on the error number? In the case of push, you can get two different errors: object is not array, or object array is full. I need to be able to do something different for each of those scenarios but I dont know WHICH error has been encountered.
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Jun 30, 2015 7:41:28 GMT -8
Super easy to do:
key.push({ error: function(status) { console.log(status.message); // Prints out error message console.log(status.code); // Prints out numeric error code } }); Hope that clears it up.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jun 30, 2015 9:00:52 GMT -8
Yeah it was the function(status) part that wasnt in the API that I needed. I figured you had something in there, I just could figure out what name you used. Eton is way better at finding those things then I am.
Thank you!
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Jun 30, 2015 12:30:02 GMT -8
Status can actually be any word you want, should just be the first variable that's passed in.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jun 30, 2015 19:08:45 GMT -8
hmmm.. I tried error.code but I didnt get anything - so I made this thread. Maybe I had some other syntax wrong.
Thank you!
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jul 1, 2015 13:52:45 GMT -8
hmmm.. I tried error.code but I didnt get anything - so I made this thread. Maybe I had some other syntax wrong. Thank you! pb.plugin.key("key").push({object_id: pb.data('user').id, value: data, success: function(){pb.window.alert('Congratulations','Saved Scuessfully.');}, error: function(error) {if(error.code == 64){ var newarray = $.grep(Array(),function(n){ return(n) }); pb.plugin.key('key').set({object_id: pb.data('user').id, value: newarray, success: function(){pb.plugin.key("key").push({object_id: pb.data('user').id, value: data, success: function(){pb.window.alert('Congratulations','Saved Successfully'); }}) } });} } }); I've always used this. It pushes to the key. However you can not push to a key that has not been set as an array yet. So if it returns code 64 I set it as a blank array and then push to it again. Also I don't know if you plan on using the shift function with multiple quantity but I would suggest avoiding it and using pop. support.proboards.com/thread/545020/report-confirmed-plugin-shift-items
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jul 1, 2015 18:47:34 GMT -8
Wont be able to use pop() with how the data needs to be organized, but I was heading the same direction as that!
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jul 1, 2015 19:25:13 GMT -8
Wont be able to use pop() with how the data needs to be organized, but I was heading the same direction as that! It is possible that they have fixed in by now. If you need the data to be organized I would place a flag in the data itself on what position it is in. I add a placeholder value into the key, remove the rest with pop. Then you can unshift them all in whatever order with something like pb.plugin.key('key').unshift({object_id: pb.data('user').id, values: dataArray,
success: function() { },
error: function(error) {}
});
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Jul 2, 2015 7:22:54 GMT -8
I believe that fix was rolled out back in early April. Let me know if that's not the case.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jul 2, 2015 9:51:21 GMT -8
Wont be able to use pop() with how the data needs to be organized, but I was heading the same direction as that! It is possible that they have fixed in by now. If you need the data to be organized I would place a flag in the data itself on what position it is in. I add a placeholder value into the key, remove the rest with pop. Then you can unshift them all in whatever order with something like pb.plugin.key('key').unshift({object_id: pb.data('user').id, values: dataArray,
success: function() { },
error: function(error) {}
}); I use placeholders for when I need to separate old from new, but in my current case Im going to be having it delete all key data upon each owner read. any data stored in the key will be unread data. but I need to either stop storing or shift out old data if the key becomes full (which hopefully doesnt become the case, but as chess surprised me I better account for the possibility). my biggest problem was getting the right error code.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,986
December 2005
horace
Wormo's Mini-Profile
|
Post by Chris on Jul 3, 2015 15:54:24 GMT -8
We bathe and trim ourselves every day and never wait for her/him to popup an error message demanding a solution (preferably sudsy), in the same vein, practice proper array key hygiene as you go ...
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Jul 3, 2015 22:19:58 GMT -8
Some keys just want to watch the world burn...
|
|