Forums > MaxMSP

newbie question about writing to a text file



Sio
Mar 15 2009 | 6:20 am

So. I have a little patch that takes the user’s input from the textedit box and then sends it to a text file that separates each word to a new line. If I can get that to work, I’m going to try to have each line read with a delay. As I have it now, the text file reads the text sent out as one line. But, the print sends each line separately. Why is that?

here’s my patch; I hope I copied it correctly…

{
"boxes" : [ {
"box" : {
"maxclass" : "newobj",
"text" : "print",
"numinlets" : 1,
"id" : "obj-2",
"fontname" : "Arial",
"patching_rect" : [ 470.0, 478.0, 34.0, 20.0 ],
"numoutlets" : 0,
"fontsize" : 12.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "text testing.txt",
"numinlets" : 1,
"id" : "obj-44",
"fontname" : "Arial",
"patching_rect" : [ 318.0, 469.0, 85.0, 20.0 ],
"numoutlets" : 3,
"outlettype" : [ "", "bang", "int" ],
"fontsize" : 12.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route text",
"numinlets" : 1,
"id" : "obj-95",
"fontname" : "Arial",
"patching_rect" : [ 266.0, 308.0, 61.0, 20.0 ],
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"fontsize" : 12.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "zl delace",
"numinlets" : 2,
"id" : "obj-93",
"fontname" : "Arial",
"patching_rect" : [ 350.0, 392.0, 58.0, 20.0 ],
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"fontsize" : 12.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "listfunnel",
"numinlets" : 1,
"id" : "obj-79",
"fontname" : "Arial",
"patching_rect" : [ 201.0, 370.0, 58.0, 20.0 ],
"numoutlets" : 1,
"outlettype" : [ "list" ],
"fontsize" : 12.0
}

}
, {
"box" : {
"maxclass" : "textedit",
"text" : " up stop late one two three four",
"numinlets" : 1,
"id" : "obj-42",
"fontname" : "Arial",
"clickmode" : 1,
"patching_rect" : [ 315.0, 66.0, 535.0, 171.0 ],
"numoutlets" : 4,
"lines" : 250,
"outlettype" : [ "", "int", "", "" ],
"fontsize" : 12.0,
"bangmode" : 1
}

}
, {
"box" : {
"maxclass" : "button",
"numinlets" : 1,
"id" : "obj-49",
"patching_rect" : [ 228.0, 98.0, 20.0, 20.0 ],
"numoutlets" : 1,
"outlettype" : [ "bang" ]
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-93", 1 ],
"destination" : [ "obj-2", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-93", 1 ],
"destination" : [ "obj-44", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-79", 0 ],
"destination" : [ "obj-93", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-49", 0 ],
"destination" : [ "obj-42", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-42", 0 ],
"destination" : [ "obj-95", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-95", 0 ],
"destination" : [ "obj-79", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}

Mar 15 2009 | 6:59 am

To copy text into the forums, you select all of your patch, then choose ‘copy compressed’ from the ‘edit’ menu and then paste it into your post(you get the text like below).

Here’s the patch so your text file shows up single lines. Not sure if I understood you correctly but i think you just need to add carriage returns(see help-file for text object). hope it helps:

— Pasted Max Patch, click to expand. —

Sio
Mar 15 2009 | 5:43 pm

Thank you! It works fine now. And also, thank you for telling me how to post my patches in forums. Smile

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > MaxMSP