Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2006
    Posts
    16

    String problem, I'm confused...

    Hi,

    I want to take a text file of urls and then assign them to several button objects which in turn open an embedded web object

    http://www.something.com
    http://somethingelse.com
    and so on...

    I've done this so far by:

    button1 = TextFile.ReadToString("C:\\url.txt");
    url = String.Mid(button1, 0, -1);
    Web.LoadURL("Web1", url);


    This is great because it will load line 1 for button 1 but how do I move on to line 2 and load that url for button 2

    I'm confused, any assistance will be greatly appreciated.

    Many thanks

    Rob

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    name your buttons 1,2,3,4,5 etc and use the below code in each button

    Code:
    tbUrl = TextFile.ReadToTable("C:\\url.txt");
    if tbURL then
    	strURL=tbUrl[String.ToNumber(this)];
    	Web.LoadURL("Web1", strURL);
    end
    simple and basic but it should work
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Apr 2006
    Posts
    16
    Thanks Rizla, I reall appreciate your help.

    tbUrl = TextFile.ReadToTable("C:\\url.txt");
    if tbURL then
    strURL=tbUrl[String.ToNumber(this)];
    Web.LoadURL("Web1", strURL);
    end
    Sorry for being such a dumbass but where am I naming buttons 1,2,3,4,5?

    Am I doing this under the properties for each button object ie Attributes/object name or is this being assigned somewhere else?

    I understand (I think) what is going on but I struggle with the code syntax somewhat.

    Thanks in advance

    Rob

  4. #4
    Join Date
    Oct 2007
    Location
    Gensokyo
    Posts
    1,324
    Yep, Call it Button1, Button2, Button3, ... and then run the code.

  5. #5
    Join Date
    Apr 2006
    Posts
    16
    Hiya,

    not quite sure what I'm doing wrong, but for some reason nothing happens when I click the buttons.

    Did I need to put any code anywhere else?

    Thanks

    Rob

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    now try it

    Code:
    tbUrl = TextFile.ReadToTable("C:\\url.txt");
    if tbURL then
    	strURL=tbUrl[String.ToNumber(String.Remove(this,"Button")];
    	Web.LoadURL("Web1", strURL);
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    May 2001
    Location
    51.531249 | -0.610962
    Posts
    1,244
    Try this:
    Code:
    strURL=tbURL[String.ToNumber(Button.GetProperties(this).ObjectName)];
    robmaggs: Watch tbURL and tbUrl case mixing. It's likely to cause headaches! Variable names are case sensitive.
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

  8. #8
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Here is an example. You may have 1 to 5 buttons, according the number of URLs in the text file.

    Ulrich
    Attached Files

  9. #9
    Join Date
    Apr 2006
    Posts
    16
    Thanks for your help, I think upeters solution might be more suitable for my project, but I'm struggling to work out how I could open URLs from a listbox.

    I see from upeters example that a table is created from a texfile and populated with two values. In my case the first one would be a website name and the second a url. When the user clicks on a selection in the list box it would open a link in a web object (Web1)

    -- read the text file
    file_table = TextFile.ReadToTable("AutoPlay\\Docs\\url_1.txt");
    for i, entry in file_table do
    -- split the line
    separator = String.Find(entry, "|");
    option = String.Mid(entry, 1, separator-1);
    action = String.Mid(entry, separator+1, -1);
    ListBox.AddItem("ListBox1", option, action);
    end

    What would I have to do to get be able to call the url value from the table and open the url in the web object.

    Sorry to be a pain, I just can't get my head around it.

    Thanks Rob

  10. #10
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Here is an updated example. I dropped the buttons of the former project and replaced them with a ListBox. Clicking on a single entry of the ListBox will load the corresponding page in the web object.

    Ulrich
    Attached Files

  11. #11
    Join Date
    Apr 2006
    Posts
    16
    That's totally awesome, Thanks so much Ulrich and everyone who helped me.

    Rob

Similar Threads

  1. Problem with passing a string variable to DLL
    By kenansoy in forum MSI Factory 2.0 Discussion
    Replies: 2
    Last Post: 12-03-2007, 09:08 AM
  2. Jukebox Enhancements
    By Zylo in forum AutoPlay Media Studio 6.0
    Replies: 2
    Last Post: 01-13-2007, 07:39 PM
  3. String Display Problem
    By Jerryab in forum AutoPlay Media Studio 6.0
    Replies: 1
    Last Post: 04-28-2006, 01:52 AM
  4. string problem with dialog messages
    By roadrunner in forum AutoPlay Media Studio 6.0
    Replies: 4
    Last Post: 02-20-2006, 02:29 PM

Posting Permissions

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