Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1001044 // saveLocally / saveLocally2

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4506L/27K).

1  
static void saveLocally(S variableName) {
2  
  saveLocally(programID(), variableName);
3  
}
4  
5  
static void saveLocally(S progID, S variableName) {
6  
  saveLocally2(mc(), progID, variableName);
7  
}
8  
9  
static void saveLocally2(O obj, S variableName) {
10  
  saveLocally2(obj, programID(), variableName);
11  
}
12  
13  
static File saveLocally2(O obj, S progID, S variableName) {
14  
  lock saveLock();
15  
  File textFile = new File(programDir(progID), variableName + ".text");
16  
  File structureFile = new File(programDir(progID), variableName + ".structure");
17  
  O x = get(obj, variableName);
18  
  
19  
  if (x == null) {
20  
    textFile.delete();
21  
    structureFile.delete();
22  
    null;
23  
  } else if (x instanceof String) {
24  
    saveTextFile(textFile, (S) x);
25  
    structureFile.delete();
26  
    ret textFile;
27  
  } else {
28  
    saveTextFile(structureFile, javaTokWordWrap(structure(x)));
29  
    textFile.delete();
30  
    ret structureFile;
31  
  }
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001044
Snippet name: saveLocally / saveLocally2
Eternal ID of this version: #1001044/4
Text MD5: 35e1dfdbec4885ac8854f4ee91c371b2
Transpilation MD5: 048d25ae4217c9a164915b4164128649
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-14 16:31:46
Source code size: 909 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 774 / 2565
Version history: 3 change(s)
Referenced in: [show references]