I'm translating over from the PHP web world and have a question on how to create a horizontal looping repeat region in Live Code? I would be using a MySQL or SQLite database for my query. Then, I want to put my results on my stack with a defined column size and then it will loop horizontally that number of times and move down a row. In HTML I'd do this with table rows & columns and some PHP code.
Here is an example of what I'm trying to accomplish (see attached).
In LiveCode, you can put lines before a list, using the syntax
put "this is a line" & cr before myList
If you have tab-delimited data, you can put another tab-delimited lines before your data using the put before syntax. You could create a field, set the tabstops of that field and put your tab-delimited data into that field. You can also update the field with the put before syntax:
put "this is a line" & cr before fld x
If you want to display multiple rows in one cell, then you might want to check out the data grid or create a group of fields, and write a script to update the data in and sizes of these fields.
Hopefully this gets you started.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
You didn't mention the word "image" in your first post. What is it that you're really trying to do? Do you just want to position pictures evenly on a card? What does it have to with databases? Maybe I don't understand "looping repeat region". Can you explain it in plain simple English?
If you want to position objects, you could do something like this (assuming you have 16 pictures of 32px wide and a margin of :
repeat with x = 1 to 4
repeat with y = 1 to 4
put x*4+y-4 into z
put x*40-32 into myLeft
put y*40 into myTop
if there is an image z then
set the topLeft of img z to myLeft,myTop
end if
end repeat
end repeat
Maybe this is what you're looking for?
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Sorry! I thought the attachment would have been clear enough to read the "Image or Text" on it but now I see that's is relatively fuzzy. Yes, my intent is to position pictures, and in some cases a fixed size text block, evenly on a card.
The database comes in because the filenames are coming from a MySQL database. Think of a photogallery being generated from a table in a MySQL database and we're making the thumbnails. And when the thumbnail is clicked it does some action. Here is an example in PHP/HTML code of what I'm attempting using a table with rows/columns.
Have you solved this problem yet? If not, then what exactly is the problem? Are you also asking how to get data from a database or do you only need to position pictures and text?
You could do something like this:
- get return and tab delimited data from database
- repeat over each line and each item of each line
- check if an item is a filename or text
- if filename, then create new image and set filename of image object
- if text then create new field and set text of field
- do a repeat loop over all new fields and images as in my example
Let me know with which part you need more help.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode