Repeats, creating multiple field boxes to mimic grid -SOLVED
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Repeats, creating multiple field boxes to mimic grid -SOLVED
Hi, New to the Revolution trying to get my head around the syntax, I normaly program web sites with PHP.
I'm trying to mimic a grid by creating multiple rows of field boxes.
The number of rows will be determined by the number of rows in a database.
So far I have this: (testing with preset values from a button action)
on mouseUp
put 100 into xpos
put 100 into ypos
put 1 into dbdfieldscountstart
put 4 into dbfieldscountend
put 5 into dbrowscount
repeat with dbrows = 1 to dbrowscount
repeat with dbfields = dbdfieldscountstart to dbfieldscountend
create field dbfields
set the location of card field dbfields to xpos,ypos
set the width of card field dbfields to 50
set the height of card field dbfields to 20
add 50 to xpos
end repeat
put 100 into xpos
add 30 to ypos
put dbfieldscountend into dbfieldscountstart
put 8 into dbfieldscountend
end repeat
end mouseUp
This creates the rows but removes each row during the next repeat which I do not understand?
Also the initial created field box remians in situ?
You may be asking 'why dosn't he use the field table?' - I want to easily specify backround colours of individual fields dependent on content. Looking through the docs and searching the forums this does not seem possible....apart from this it's also a good exercise for me.
Any help will be much appreciated.
Andy
I'm trying to mimic a grid by creating multiple rows of field boxes.
The number of rows will be determined by the number of rows in a database.
So far I have this: (testing with preset values from a button action)
on mouseUp
put 100 into xpos
put 100 into ypos
put 1 into dbdfieldscountstart
put 4 into dbfieldscountend
put 5 into dbrowscount
repeat with dbrows = 1 to dbrowscount
repeat with dbfields = dbdfieldscountstart to dbfieldscountend
create field dbfields
set the location of card field dbfields to xpos,ypos
set the width of card field dbfields to 50
set the height of card field dbfields to 20
add 50 to xpos
end repeat
put 100 into xpos
add 30 to ypos
put dbfieldscountend into dbfieldscountstart
put 8 into dbfieldscountend
end repeat
end mouseUp
This creates the rows but removes each row during the next repeat which I do not understand?
Also the initial created field box remians in situ?
You may be asking 'why dosn't he use the field table?' - I want to easily specify backround colours of individual fields dependent on content. Looking through the docs and searching the forums this does not seem possible....apart from this it's also a good exercise for me.
Any help will be much appreciated.
Andy
Last edited by AndyP on Thu Sep 11, 2008 5:05 pm, edited 1 time in total.
I've done similar things before, like when I made a color palette program that needed 256 squares for 256 colors. Here's basically what I did:
There might be better ways to do this, but this is just how I did something like this before.
Code: Select all
on mouseUp
put 10 into varRows
put 10 into varCols
put 1 into varNameCounter
put 40 into varPosTop
put 30 into varPosLft
lock screen
repeat varCols times
repeat varRows times
put "dbfields" & varNameCounter into varName
create field varName
set the width of field varName to 50
set the height of field varName to 20
set the left of field varName to varPosLft
set the top of field varName to varPosTop
put varPosTop + 20 into varPosTop
put varNameCounter + 1 into varNameCounter
end repeat
put 40 into varPosTop
put varPosLft + 50 into varPosLft
end repeat
unlock screen
end mouseUp
Great . Thanks
Hi Garrett
Thanks, that really helps.
Very impressed with the response to my first call for help.
Andy
Thanks, that really helps.
Very impressed with the response to my first call for help.
Andy
Repeats....
AndyP
Don't get into the situation I had experimenting
with something similar. I was cloning a small
graphic and trying various methods - and using
different names for them.
If you don't have a way to delete the generated
fields they pile up and when you get to 2,000 or
so (very easy to do) the Inspector will give an error
of "Too many objects to display".
Very disconcerting (and time-wasting) to say the least.
I had to knock out a script (party guessing the
various names I'd given them ) and run it
repeatedly in a loop until I reduced them to a
number which didn't upset the Inspector.
Don't get into the situation I had experimenting
with something similar. I was cloning a small
graphic and trying various methods - and using
different names for them.
If you don't have a way to delete the generated
fields they pile up and when you get to 2,000 or
so (very easy to do) the Inspector will give an error
of "Too many objects to display".
Very disconcerting (and time-wasting) to say the least.
I had to knock out a script (party guessing the
various names I'd given them ) and run it
repeatedly in a loop until I reduced them to a
number which didn't upset the Inspector.
Life is just a bowl of cherries.
Repeats
If you name them something0001, something0002 etc
the you can do
repeat with i = 1 to 1000
if exists(field ("something"&i)) then
delete field ("something" & i)
end if
end repeat
(just from memory)
I had multiple copies with the same names (Rev
doesn't seem to mind) so I had to put all the
above in another loop (1 - 99) to get rid of them
all.
Even if your app doesn't need a "Reset" button you
could put one on just for getting rid of the rubbish and
remove it when you've got it sorted.
There's also a plug-in which can handle up
to 10,000 objects. It was mentioned in one
of the responses to my query on this subjet.
Just had a look - it's called RevNavigator from
www.inspiredlogic.com/navigator.
the you can do
repeat with i = 1 to 1000
if exists(field ("something"&i)) then
delete field ("something" & i)
end if
end repeat
(just from memory)
I had multiple copies with the same names (Rev
doesn't seem to mind) so I had to put all the
above in another loop (1 - 99) to get rid of them
all.
Even if your app doesn't need a "Reset" button you
could put one on just for getting rid of the rubbish and
remove it when you've got it sorted.
There's also a plug-in which can handle up
to 10,000 objects. It was mentioned in one
of the responses to my query on this subjet.
Just had a look - it's called RevNavigator from
www.inspiredlogic.com/navigator.
Life is just a bowl of cherries.