Beginners Questions

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Beginners Questions

Post by bjb007 » Mon Jan 21, 2008 1:01 am

I have a text file with a list of numbers...

1,2,4,13, etc.

I want to delete the last number.

Can't see a command "go to EOF" or similar except
"read from file myfile until EOF" which seems like going
the long way around.

Also need to delete from EOF to the character before the
next "," which might mean deleting two or three characters
depending on the last number.

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Mon Jan 21, 2008 1:16 am

bjb, this is how I'd do it:

Code: Select all

put url ("file:" & myFile) into myData
delete item -1 of myData
put myData into url ("file:" & myFile)

the 'url' syntax lets the engine take care of actually open/reading/writing/closing the file, and 'item' is one of Revolution's chunk expressions - have a look at the entries for 'item', 'word' and 'line' in the docs.

Two important things to know about Revolution:

1: Chunk expressions tend to be very efficient.
2: Pass whatever work you can to the engine because it tends to be very efficient.

Best,

Mark

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

More simple questions

Post by bjb007 » Fri Feb 01, 2008 7:30 pm

Thanks Mark. That works fine.

Now I want to get a number from the same file and display
it on the form. Don't want it to be editable.

Expect that if I use a grid and make it non-editable I won't
be able to change the number displayed programmatically.
(Revision: found a reference which says that it can still be
edited programmatically.)

Can't see anything specifically for that but could use a label
I guess. What's the best way to do this?

Tried a Table Field but can't put into one cell. Setting
format to 'centre' puts into middle of three, 'left' puts
into left. Need a way to address one 'cell' of three.
Tried as for an array [1], [1,1] etc. but doesn't work.

Post Reply