-
separate variables in txt file
I have a bunch of variables in a txt file and I want to be able to separate them a little so I can see what the hell is going on. How can I space them out.
Right now it looks like this
Code:
tall=pic0,pic1,pic2,pic3,pic4,pic5&dom=pic0,pic1,pic2&fran=pic0,pic1,pic2&paul=pic0,pic1,pic2&sim=pic0,pic1,pic2,pic3&adrem=pic0,pic1,pic2&sis=pic0,pic1,pic2,pic3,pic4,pic5&cam=pic0,pic1,pic2,pic3,pic4,pic5,pic6&damp=pic0,pic1,pic2
There is more but just for the example I just placed a few together. I would like to have them all on there own line and maybe another line brake between them. This would help in editing down the line. Right now when I go back after a week or two away from the site I have no idea what the hell is going on for a few minutes. It’s hard to edit something that you can’t see very well.
-
FK'n_dog
use ampersand -
tall=pic0,pic1,pic2,pic3,pic4,pic5&
&dom=pic0,pic1,pic2&
&fran=pic0,pic1,pic2&
&paul=pic0,pic1,pic2&
&sim=pic0,pic1,pic2,pic3&
&adrem=pic0,pic1,pic2&
&sis=pic0,pic1,pic2,pic3,pic4,pic5&
&cam=pic0,pic1,pic2,pic3,pic4,pic5,pic6&
&damp=pic0,pic1,pic2&
hth
-
So I can also do this
Code:
tall=pic0,pic1,pic2,pic3,pic4,pic5&
&
&dom=pic0,pic1,pic2&
Great it was that easy.
-
Ok I have tried this and am getting a very strange layout of my buttons.
Code:
larissa=pic0,pic1,pic2,pic3,pic4,pic5&
&dominique=pic0,pic1,pic2&
&francesca=pic0,pic1,pic2&
&octavia=pic0,pic1,pic2&
&simone=pic0,pic1,pic2,pic3&
&adriana=pic0,pic1,pic2&
&alva=pic0,pic1,pic2,pic3,pic4,pic5&
&camille=pic0,pic1,pic2,pic3,pic4,pic5,pic6&
&dionne=pic0,pic1,pic2&
&florence=pic0,pic1,pic2,pic3,pic4,pic5&
&inessa=pic0,pic1,pic2&
&juliette=pic0,pic1,pic2,pic3&
&ophelia=pic0,pic1,pic2,pic3&
&rose=pic0,pic1,pic2,pic3&
&view
all=dominique,larissa,francesca,octavia,simone,adriana,alva,camille,dionne,florence,inessa,juliette,ophelia,rose&
Now here is my arangement of buttons that are created from this.
Code:
view all
rose
ophelia
juliette
inessa
florence
dionne
camille
alva
adriana
simone
octavia
francesca
dominique
larissa
There is a big gap between dominique and larissa. This effects the layout of my buttons.
-
-
FK'n_dog
how are you loading the variables from the text file ?
loadVars is the reliable MX method.
if using loadVariables, add a final pair to the text - &eof=yes&
and do a looping check for eof=="yes" before trying to use the variables, or load to a clip and use onClipEvent(data)
also, in Test Movie mode, use keyboard shortcut Ctrl / Alt / V
to Show Variables and check all arrays.
hth
-
Ok this is part of the load function I have built the rest of it separates the names from the values and then creates buttons. I didn't add this is because it might confuse everything.
But this is the main load function
Code:
function loadArr(file) {
arr_obj = new LoadVars();
arr_obj.onLoad = function(success) {
if (success) {
var coll_menu_Array = new Array();
collectionButtArray = new Array();
// Loop through all the properties of this which is the arr_obj variable
//push every properties except the onLoad which is lumped in there wit all the rest
for (var i in this) {
// if all the rest except onload are equal to i then push them into an array
if (i != "onLoad") {
coll_menu_Array.push(i);
coll_menu_Array.sort();
trace(i);
}
}
}
};
arr_obj.load(file);
}
loadArr("arr.txt");
-
Ok this worked perfectly don't know why but it did. Maybe someone can tell me why this worked
by using r\n it works without giving you that extra line like the ampersand does
Code:
view
all=dominique,larissa,francesca,octavia,simone,adriana,alva,camille,dionne,florence,inessa,juliette,ophelia,rose
\r\n
&larissa=pic0,pic1,pic2,pic3,pic4,pic5
\r\n
&dominique=pic0,pic1,pic2
\r\n
&francesca=pic0,pic1,pic2
\r\n
&octavia=pic0,pic1,pic2
\r\n
&simone=pic0,pic1,pic2,pic3
\r\n
&adriana=pic0,pic1,pic2
\r\n
&alva=pic0,pic1,pic2,pic3,pic4,pic5
\r\n
&camille=pic0,pic1,pic2,pic3,pic4,pic5,pic6
\r\n
&dionne=pic0,pic1,pic2\
\r\n
&florence=pic0,pic1,pic2,pic3,pic4,pic5
\r\n
&inessa=pic0,pic1,pic2
\r\n
&juliette=pic0,pic1,pic2,pic3
\r\n
&ophelia=pic0,pic1,pic2,pic3
\r\n
&rose=pic0,pic1,pic2,pic3
-
FK'n_dog
does this help
function loadArr(file) {
arr_obj = new LoadVars();
arr_obj.onLoad = function(success) {
if (success) {
coll_menu_Array = new Array();
collectionButtArray = new Array();
for (var i in this) {
if (i != "onLoad") {
coll_menu_Array.push(i);
coll_menu_Array.sort();
isloaded = true;
}
}
}
};
arr_obj.load(file);
}
loadArr("arr.txt");
this.onEnterFrame = function(){
if(isloaded){
coll_menu_Array.splice(0,1);
for (var arr=0; arr<coll_menu_Array.length;arr++){
trace("coll_menu_Array["+arr+"] "+coll_menu_Array[arr]);
}
delete this.onEnterFrame;
}
};
-
What is this
Code:
for (var arr=0; arr trace("coll_menu_Array["+arr+"] "+coll_menu_Array[arr]);
If I use this is won't work.
I have all the varaibles loading the problem was getting rid of that extra line when they had loaded.
and the \r\n did that for me.
But I am interested why you used this code above.
thanks for your replies on this
-
FK'n_dog
duff copy / paste remove comments // to view affect on array structure
this.onEnterFrame = function(){
if(isloaded){
//coll_menu_Array.splice(0,1);
for (var arr = 0; arr < coll_menu_Array.length; arr++){
trace("coll_menu_Array["+arr+"] "+coll_menu_Array[arr]);
}
delete this.onEnterFrame;
}
};
// without splice
coll_menu_Array[0]
coll_menu_Array[1] adriana
coll_menu_Array[2] alva
coll_menu_Array[3] camille
coll_menu_Array[4] dionne
coll_menu_Array[5] dominique
coll_menu_Array[6] florence
coll_menu_Array[7] francesca
coll_menu_Array[8] inessa
coll_menu_Array[9] juliette
coll_menu_Array[10] larissa
coll_menu_Array[11] octavia
coll_menu_Array[12] ophelia
coll_menu_Array[13] rose
coll_menu_Array[14] simone
coll_menu_Array[15] view all
// with splice
coll_menu_Array[0] adriana
coll_menu_Array[1] alva
coll_menu_Array[2] camille
coll_menu_Array[3] dionne
coll_menu_Array[4] dominique
coll_menu_Array[5] florence
coll_menu_Array[6] francesca
coll_menu_Array[7] inessa
coll_menu_Array[8] juliette
coll_menu_Array[9] larissa
coll_menu_Array[10] octavia
coll_menu_Array[11] ophelia
coll_menu_Array[12] rose
coll_menu_Array[13] simone
coll_menu_Array[14] view all
hey presto : no space
hth
-
cool nice one thanks for your help on this. Now does anyone know why putting r\n after every line in the txt file got rid of that space without using the enterFrame and splice function?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|