// Loop over all subtools, // Grab subtool name, write to file [VarDef, myWriteStr, ""] [VarDef, memOffset, 0] [VarDef, myBytes, 0] [VarDef, newLine, [StrMerge, [StrFromAsc, 13], [StrFromAsc, 10]]] // [VarDef, myFilePath, ""] [VarDef, myFileName, "subtools.txt"] // DEFine the string [VarDef, msg, ""] // Define it (once when script is loaded) [VarSet, msg, ""] // set it at restart [VarDef, tempStr, ""] [VarSet, tempStr, ""] [RoutineDef, WriteMem, [MemResize, ZB_TextOutputMem, [MemGetSize, ZB_TextOutputMem] + 256] [VarSet, myBytes, [MemWriteString, ZB_TextOutputMem, pStr, memOffset, 0]] [VarSet, memOffset, memOffset + myBytes] [MemResize, ZB_TextOutputMem, memOffset] , pStr]//end routine [IButton, "Write subtools names", "Writes out all sub tools names!", // create variable equal to number of sub tools [VarSet, len, [SubToolGetCount]] [MemDelete, ZB_TextOutputMem] // just makes sure this isn't around [MemCreate, ZB_TextOutputMem, 256] // create memblock [VarSet, memOffset, 0] [VarSet, myBytes, 0] //[VarSet, msg, ""] // set it at restart [VarSet, tempStr, ""] // loop over array [VarSet,i,0] //Note with time of -1 combines Note with next shown [Note, [StrMerge, "Number of subtools: ", [Val,len], "\n\n"],,-1] [Loop,len, // select current sub tool [SubToolSelect,[Val,i]] // change subtoolName to the current subtool name [VarSet, subtoolName, [IGetTitle,Tool:Subtool:Item Info]] // shorten the string so it doesn't have a . at the end [VarSet, subtoolName, [StrExtract, subtoolName, 0, [StrLength, subtoolName]-2]] // set the message to concatenate //[VarSet, msg, [StrMerge, msg, subtoolName, newLine]] [Note,[StrMerge,subtoolName,"\n"],,-1] [VarSet, tempStr, [StrMerge, subtoolName, newLine]] [VarInc, i] // i++ // write to memory block [RoutineCall, WriteMem, tempStr] ] // end loop // write to file //when done, write memblock to file... [VarSet, myFilePath, myFileName] // path to file - this example will be in the same location as this zscript [VarSet, lBytes, [MemSaveToFile, ZB_TextOutputMem, myFilePath, 1]] // will overwrite existing file [MemDelete, ZB_TextOutputMem] //all done, delete memblock [If, lBytes > 0, [Note, [StrMerge,"\n", [Val, lBytes], " bytes written to file:\n", myFileName],, 15] , //else an error [Note, [StrMerge, "Error in writing file, dude! ", [Val, lBytes]],, 5] ] // end if // show number of subtools //[Note, [StrMerge, "Number of subtools: ", [Val,len], "\n", msg],,15] ] // end button