Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2005
    Posts
    7

    Grin Dynamic Page Updates

    Hi Guys

    I am currently working on a fairly large project (for a noob like me) and I am trying to think of a way to change a page's contents completely at run time.

    The project is like a library of books. As you open the project it will display images of 12 books, if you then click the next page button it will then show you another page of books starting with the same letter, and if you click the next letter button it will jump to the next letter. And so on

    Up until now most of the work has been very and I mean simple work flows
    click a button -> jump to page
    click a button -> run application
    click a button -> exit

    Only now am I trying to use scripts to do multiple actions at once and it seems to be a minefield of possibilities.

    I could easily spend weeks creating pages, getting it running fine and looking pretty, but if I then need to ammend the contents in anyway I would have essentially start ammending every page.

    So I was trying to find out if I could enter all my data such as name, cover image, and pdf document in a table and then at run time call from that table and populate the page.

    I have managed to update the page manally using Image.Load in the preload scripts in the page as well as Image.SetPos to move the files into the correct places on the background, but as stated the project is always being updated and I still don't fully understand tables even after watching Corey's videos over and over.

    So if anyone can help with any ideas I would be greatly appreciated.

  2. #2
    Join Date
    Aug 2011
    Posts
    9
    Will this help? Check globals code
    Cheers
    Attached Files

  3. #3
    Join Date
    Oct 2005
    Posts
    7
    Cheers colc for the input, but I need to find if it is possible to enter the data from my collection as a table and then populate the page with different images and have them load a corresponding file.

    For example

    books = {};
    books1 = {Title="Charlie & The Chocolate Factory", Author="Roald Dahl", Cover="340.jpg", File="ccf.pdf"};
    books2 = {Title="Into the Darkest Corner", Author="Elizabeth Haynes", Cover="633.jpg", File="dark.pdf"};
    books3 = {Title="The DaVinci Code", Author="Dan Brown", Cover="43.jpg", File="davinci.pdf"};

    ... and so on

    I'd like to be able to list all the books alphabetically from my list, and them display the jpg related to it and then once the button is selected load the pdf, and then at a later date, I would add more books to my collection I can simply enter a new line into the books table and continue from there without having to alter everything to fit

    Firstly I'd like to know if this is even possible, and if so how I would go about it

    Many Thanks In Advance

  4. #4
    Join Date
    Aug 2003
    Posts
    2,468
    I would do it all dynamically. That way you can add to or change the application content files without changing your code.

    All you need to do is give associated files the same name e.g. "The Bible.pdf", "The Bible.jpg", "The Bible.wmv", "The Bible.mp3" then read the documents into say a list box at run time and programme the actions in the listbox 'on select' to load or play the appropriate files by using the filename concatenated with the filename extension to reference the associated files.

  5. #5
    Join Date
    Oct 2005
    Posts
    7
    Thanks I may try this, by sticking only the titles into the table I should be able to populate the screen with images using a for loop on the table and with every index position the image in a different place. And as you said if I Concat the pdfs I'll be able to set the image to run the pdf at runtime.

    Cheers just a couple more questions
    a) I have seen that you can sort into a-z format using Table.Sort but can you for example only output files starting with a specific letter, otherwise I may have to use 27 tables to organise my library.
    b) Can you use a variable for the ToolTip or does it have to be a string?

    Cheers Guys You Are Awesome

  6. #6
    Join Date
    Aug 2003
    Posts
    2,468
    This is a quick 2 minute example of what I'm talking about. It loads text to a paragraph and a jpeg to an image depending on the selection in the list box. The contents of the listbox are created dynamically in the page on show. Put a different set of text files and images in and as long as they are suitably named it will work without changing anything.

    p.s. - obviously this isn't supposed to be a finished work by any means
    Attached Files

  7. #7
    Join Date
    Oct 2005
    Posts
    7
    Just to update, I have thought of a way to populate the screen from various tables by renaming a different table each time, from a single piece of data.

    The example below is taking data from a input box, but I should be able to get data from anything as long as I know what to ask for.

    If I am going about this the wrong way please let me know

    Paul
    Attached Files

  8. #8
    Join Date
    Aug 2003
    Posts
    2,468
    I think that the fun lies in experimenting - make mistakes and then learn from them. If you ask 5 people the best way to do something you'll get 5 different answers, although code can always be improved I don't think you can ever say there is a 'right way' to do things just ways that work more effectively than others.
    Last edited by longedge; 04-28-2012 at 04:34 PM.

  9. #9
    Join Date
    Oct 2005
    Posts
    7

    Recap

    Thanks longedge, you must have been typing the same time I was, I see what you mean, but can I verify a few things about this


    tfiles = File.Find("AutoPlay\\Docs", "*.txt", false, false, nil, nil);
    if tfiles then
    for i,v in pairs (tfiles) do
    sfile = tfiles[i]
    tsplit = String.SplitPath(sfile);
    result = ListBox.AddItem("ListBox1", tsplit.Filename, sfile);
    end
    end

    Correct me if I am wrong, but this action firstly searches the directory 'Docs' for any file that has an extension of 'txt' and puts it into a table marked 'tfiles'
    it then indexes the files and copies to a variable of 'sfile'
    This then places its full file address into a table marked 'tsplit' which then results in the listbox being populated with just the filename pulled from the 'tsplit' table.

    Am I right?

  10. #10
    Join Date
    Aug 2011
    Posts
    9
    I think a database may be the way to go for your collection of books.Try this example from v7.5 to give you an idea.Your images can be stored as well in database
    Hope this helps
    Attached Files

  11. #11
    Join Date
    Aug 2003
    Posts
    2,468
    Quote Originally Posted by Flashpc View Post
    Am I right?
    That's it except that listbox items contain two pieces of information, the item text and the item data and the data added in each case is the path and file for each item "sfile".

    When you select an item in the listbox, that data is used to load the file to a string which then populates the paragraph object.

    I create CD's for deploying training and reference materials and have sometimes had to produce several projects a day containing dozens of files. Using this method means you don't have to worry about inputting any information yourself provided you get the file naming right. I re-use a project and just drop a new set of files into it before burning my master.

    One size doesn't fit all - it suits my purposes to work this way but it might not be the best for you - just one way of many

  12. #12
    Join Date
    Oct 2005
    Posts
    7

    Thumbs up Eureka

    Thanks to your example I am beginning to get a handle on for loops, and now I have created a couple of functions to display, data from a for loop which was a relief after I coded it and it worked, It was a Eureka moment, I then streamlined the code to reuse some of the variables I altered the functions to receive more variables and then altered the frontend to display dynamic information.

    While it is working this is fun!!

    This is definitely a huge step forward towards my library project, as long as the filenames are correct, it should populate the screen nicely with all the front covers

    Thank You So Much.

    Below is a concept program, it searches a folder (listfolder variable in project actions) for whatever you want (ext variable in project actions)

    In the default it searches for txt files in the docs folder

    Again Thanks to longedge and colc for your time
    Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts