Results 1 to 4 of 4

Thread: Download file with simba

  1. #1
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default Download file with simba

    Hi,

    how can I use Simba to download a file from the internet and save it as .jpg for example ?

    Hope you can help

    caused

  2. #2
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default

    I used this to download sps maps for my scripts if they werent present! Credit goes to The Mayor

    Simba Code:
    procedure checkForFile(path, url, name: String);
    var
      itemName: String;
      itemFile: LongInt;
    begin
      itemName := appPath + path;

      if fileExists(itemName) then
      begin
        writeLn(name + ' already exists');
        exit();
      end;

      writeLn('Downloading ' + name);
      showMessage('You''re missing the ' + name + chr(13) + chr(13) + 'Downloading it now!');

      closeFile(createFile(itemName));
      itemFile := reWriteFile(itemName, false);
      writeFileString(itemFile, getPage(url));
      closeFile(itemFile);
    end;

    then an example to put this to use would be

    Simba Code:
    checkForFile('Includes/SPS/img/runescape_surface/CourseSurface_0.png', 'http://i.imgur.com/3vZAOVm.png', 'Course Surface Map');

    not sure what other file types it would support, as i haven't tried anything else.

  3. #3
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks I tried getpage(); as well but It didnt really work, but writeFileString works great ... Thanks.
    I edited your function to this:

    Code:
    procedure downloadFile(path, url: String);
    var
      itemName: String;
      itemFile: LongInt;
    begin
      writeLn('Downloading ' + url);
      closeFile(createFile(path));
      itemFile := reWriteFile(path, false);
      writeFileString(itemFile, getPage(url));
      closeFile(itemFile);
    end;

  4. #4
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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