Skip navigation

applescript pointer to read location in file

442 Views 6 Replies Latest reply: Mar 1, 2013 10:36 AM by Frank Caggiano RSS
madelefant Calculating status...
Currently Being Moderated
Feb 11, 2013 3:34 PM

In trying to do some Applescript programming that reads from a file I've hit a bit of roadblock. The applescript documentation refers to a pointer to the current read location in a file, but gives no listing of accessing it as a reference. For example. I have a file and I do a read unitl "whatever character."  It would seem highly useful there be a way to access the new or current read location as a built in propery or something.  It looks like the only way to really do this is to make your own secondary property/variable enumerating your position? So you have to set up a way to have a varialble that has a count of how far it has read in integer or character wise?


Maybe i am missing something.



  • Frank Caggiano Level 7 Level 7 (22,830 points)
    Currently Being Moderated
    Feb 11, 2013 5:46 PM (in response to madelefant)

    Perhaps if you explained what you were trying  a way could be suggested.


    Why do you need the absolute value of the file pointer?

  • Frank Caggiano Level 7 Level 7 (22,830 points)
    Currently Being Moderated
    Feb 11, 2013 8:04 PM (in response to madelefant)

    How large is the file? Might be more efficient if you read the whole thing in and did the work in memory.


    Can you post some of the file or make it available online. Might be easier to visualize the problem if we can see the file.

  • Frank Caggiano Level 7 Level 7 (22,830 points)
    Currently Being Moderated
    Mar 1, 2013 10:36 AM (in response to madelefant)

    Given the layout of the servers file 9as shown in the example you posted) this code will read it into a list (aa) with the servename as one list item and the servers for tat serve as the next list item



    set fnum to open for access (((path to desktop) as text) & "Serverlist.txt")


    set aa to read fnum using delimiter {space, "[", "]"}


    repeat with i from 1 to length of aa

              if item i of aa is equal to "AfterNet" then

                        display dialog item (i + 1) of aa

              end if

    end repeat




    Depending on the file size and you machine this shouldn't be to much to run. You might want to give it a shot. With this then you can simply enter the serve name you are looking for and then access all its servers.


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.