Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blackangel

macrumors newbie
Original poster
Sep 16, 2007
3
0
Rotherham, England
I'm trying to set up an apple script that will:
  1. Search a 'Numbers' document/.txt document to find a barcode
  2. And then display the price and item in a display dialog box
  3. And then allow me to add other items
  4. And then give me a total
I know it sounds complicated, but i cant afford POS software and i thought this might be a cheap alternative.
But i only have very basic apple scripting skills.
Thanks in advance
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Though I don't follow what you want exactly, I don't think AppleScript is the appropriate tool for the job.
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
FileMaker Pro would be a better solution, in fact there may be a pre-made solution already available requiring only to be filled in with the details.

You will just have to accept low-cost as opposed to no-cost offerings.
 

mkaake

macrumors 65816
Apr 10, 2003
1,153
0
mi
Something like this could be done more readily by combining Excel with Applescript, but to do it all with Applescript, as stated, is not really a good way to do it. I'd suggest either spending money on a low-level POS system (as mentioned in the post above), or operating the old fashioned way - looking up values by hand, and adding them together with a calculator :)
 

blackangel

macrumors newbie
Original poster
Sep 16, 2007
3
0
Rotherham, England
I think I Wasn't Quite Clear

i know my previous post confused people, so i'll try and explain it a bit clearer this time.

I'd like to make an apple script that will work in conjunction with a spreadsheet program like excel, to display price etc when a item is scanned.

Thanks in advance
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
i know my previous post confused people, so i'll try and explain it a bit clearer this time.

I'd like to make an apple script that will work in conjunction with a spreadsheet program like excel, to display price etc when a item is scanned.

Thanks in advance

What do you mean by "scanned"? I have written scripts that will do some work on text that is currently copied to the clipboard. Would that work?
 

mkaake

macrumors 65816
Apr 10, 2003
1,153
0
mi
It sounds like he'll just be using a scanner as a POS system... so you scan, it pops up the x digit product code, and immediately does a vlookup in Excel. It would then take the found value, and add it to a list for the current 'purchase'.

Of course, you'd actually be doing a few vlookups, on multiple columns, because you (well, maybe not in this case) track taxable / non taxable items.

To me, it seems like the first few questions would be...

a) are you *only* using the barcode scanner for input?

Well, actually, that's the first one.

If that's your only input source, the applescript will have to know when the input is complete (maybe count the number of characters that have been 'typed' in?). Secondly, you have to have a way to know when you're starting and ending transactions - if you only have a barcode scanner, you could probably have some barcodes set up to start and stop a transaction, as well as view a total.

Still not sure how much time you'll actually save doing this, unless you are *simply* looking for a display to pop up with the price, that someone will then type in to a cash register. I might play around with it a little bit tomorrow, but I don't have my scanner yet (waiting for it in the mail for scanning in my library).

If it's just a quick price lookup (and display one price at a time on screen), it should be a quick n dirty script. It would look a lot better if you did it as applescript studio, and throw a nice interface on it. It would be easy enough then to have a display with the item name, price, and whatever pop up.

Of course, I just like playing in interface builder...
 

mkaake

macrumors 65816
Apr 10, 2003
1,153
0
mi
Well, I actually threw together an application (applescript studio FTW!), but in my debug process, I found out that Excel 2004 (I'm using Excel X) completely changes its applescript dictionary. So not only am I having some issues with the finer points (and still don't know how it works with an actual barcode scanner...), but if you're using an up to date version of excel (or hey, one that's almost 4 years old), this won't work for you at all.

So basically, yes, it's doable. Very doable. Stupid easy, until you throw an interface at it. Then it's just time (I'm not too good yet at combining interfaces with applescript, so I loose a lot of time on stupid things).

If you just want to see how the (very very very) basic version is with nothing but Applescript, it would look something like this... assuming you have an excel workbook set up like this:

On a worksheet named 'Lookup', cell A1 is your item number input (your PLU). Cell A4 is a vlookup (for my quick throw together, =VLOOKUP(Lookup_Number, Item_Database, 2, FALSE) ). Cell A5 is a vlookup (=VLOOKUP(Lookup_Number, Item_Database, 3, FALSE)). For both of these, the database named range is on a different tab, and could be all columns on the page if you'd like, as long as row A is the PLU. On my sheet, row 2 and 3 of the database are the item name and price, respectively.

Note - for some (really) strange reason, any numbers formatted as currency will pass a null value to Applescript - so don't do it.

Anyhew, with that basic setup, this is what the very simple applescript would look like for Office X:

Code:
global display_1
global display_2
global lookup_value

initialize()
excel_lookup()


on button_click()
	
end button_click

on excel_lookup()
	
	tell application "Microsoft Excel"
		set Value of Cell "A1" to lookup_value
		set display_1 to Value of Cell "A4"
		set display_2 to Value of Cell "B4"
		
	end tell
	
	
	display dialog display_1 & return & return & "$" & display_2
	
end excel_lookup
on initialize()
	tell application "Microsoft Excel"
		Activate
		Activate Workbook "sample.xls"
		Activate Worksheet "Lookup"
	end tell
	tell application "System Events"
		set visible of process "Microsoft Excel" to false
	end tell
	
end initialize

If you have a keyboard available, you can run this applescript (or some variant thereof), scan a barcode, hit enter, and it'll come back with your item description and cost.

Again, this can be made pretty (and remove the need for a keyboard), but it would be a huge waste of my time to throw it together for Office X, and I don't have a copy of Office 2004.

<edit> Come to think of it, I've already wasted my time on it, but I haven't polished it... not much point though. This should get you going - the changes you'd need to make to this for Excel 2004 would be minimal, and it works. And it's free, which I believe meets your original requirement :D
 

mkaake

macrumors 65816
Apr 10, 2003
1,153
0
mi
Thanks everyone for your help.

Do you know if the code would work on open office.

There's a quick way you could check that.


So from the sounds of things, you're trying to go 100% free. Completely free.

It might be wise to consider that if you're putting yourself in a situation where you're trying to sell something (in quantities and variation that will require the use of a POS system), that you should really spend some money on infrastructure.

I don't think that you'll get applescript to talk to OO (or NeoOffice, for that matter). Maybe AppleWorks. That said, the difficulty in getting things to work is going to increase exponentially the less money you try to spend.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.