Isolating and displaying imported file names

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
monkey
Posts: 9
Joined: Mon Feb 17, 2014 9:38 pm

Isolating and displaying imported file names

Post by monkey » Sun Mar 09, 2014 9:30 am

Hi All,

I can import a text file and load its content into an array or Datagrid. Yay me.

BUT... How do I isolate the file name and display it in a label field?

So, if the text file was called "my text file" (they're being saved without the ".txt" extension and I really don't see a need to change that), I would want to have "my text file" displayed in a label just above the datagrid that holds all of the file's contents.

All help appreciated!

monkey
Posts: 9
Joined: Mon Feb 17, 2014 9:38 pm

Re: Isolating and displaying imported file names

Post by monkey » Sun Mar 09, 2014 9:45 am

Alternatively:

Is it possible to put information in the text field before the main array content and filter it off on retrieval?

For example, if my text file was a collection of a student's subjects and grades, could it be saved as:

Name: Random Student
Class: 10QC

Subject [tab] Mock Grade [tab] Challenge Grade [return]
Biology [tab] B [tab] A* [return]
...etc

So... I'd want to take the first two lines and display them on the card above the datagrid which will contain the main information below.

Any thoughts?

Thanks again

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Isolating and displaying imported file names

Post by BvG » Sun Mar 09, 2014 10:57 am

To display stuff on a card you should use a field. Then you can use code to put stuff into the field, for example:

Code: Select all

set the itemDelimiter to tab
answer file ""
put it into myPath
put item -1 of myPath into field "filename"
Your second question, as far as I understand it, is about how to put the two first lines of text into one field, and the rest into another field (or a datagrid):

Code: Select all

answer file ""
put url ("file:" & it) into myList
put line 1 to 2 of myList into field "header data"
put line 3 to -1 of myList into field "actual data"
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

monkey
Posts: 9
Joined: Mon Feb 17, 2014 9:38 pm

Re: Isolating and displaying imported file names

Post by monkey » Sun Mar 09, 2014 11:17 am

Thanks!

:)

Post Reply