עדכון משתנה ב google script ואיך מוסיפים סיפרה ל 000
-
אני רוצה לעדכן משתנה בכל הרצה כשהפעם הראשונה זה 000 שנייה 001 וכו'
אין לי ידע כ"כ טוב בתכנות ובפרט לא ב JS -
@אנא נראה לי זה יעזור לך.
https://developers.google.com/apps-script/guides/properties
זה לכאורה אותו רעיון של localStorage, רק במימוש שונה של google script. -
@מוטי-אורן עכשיו הצלחתי לשמור ולשלוף
אבל אני לא מצליח לתת לו פקודה שתהפוך את 000 ל 001
זה מה שהגדרתיvar userProperties = PropertiesService.getUserProperties(); var units1 = userProperties.getProperty('name'); if (units1 = null){ var userProperties = PropertiesService.getUserProperties(); userProperties.setProperty('name', '000'); } var userProperties = PropertiesService.getUserProperties(); userProperties.setProperty('name', units1 + 1); var userProperties = PropertiesService.getUserProperties(); var units = userProperties.getProperty('name');
והתוצאה היא שאחרי 000 מגיע 1.0 ואחריו 1.01 ואחריו 1.011 וכו'
-
@אנא הקוד הבא אמור לתת לך מענה
אבל לא השתמשתי במשתנה ספציפי
ובאמת מעניין מבחינת האלגוריתם
איך מוסיפים אפסים מוביליםfunction myFunction() { var txetFile for (var counter = 0; counter <= 100; counter = counter + 1) { if (counter<100) {txetFile = "0" + counter}; if (counter<10) {txetFile = "0" + txetFile}; Logger.log(txetFile); } }
-
dovid
-
@מנחם אני עשיתי ככה וכשהשתמשתי יצא המספר 099
-
מצו"ב מחדש
עם השורה שפספסתי מקודםfunction myFunction() { var txetFile for (var counter = 0; counter <= 100; counter = counter + 1) { txetFile=counter; if (counter<100) {txetFile = "0" + counter}; if (counter<10) {txetFile = "0" + txetFile}; Logger.log( txetFile.toString() ); } }
-
@מנחם אתה בעצם מריץ את כל המספרים אבל לא עצרת אותם (הלולאה שעשית נגמרת רק אחרי שזה מגיע אל 100)
דרך מה שעשית אני יכול להסתדר אבל עכשיו זה כבר לא רלוונטי