YA Table Problem... or opportunity if you look at that way.

All I’m trying to do is get some user input data into a table. I’ve spent the last couple of days looking here and through the xcode help and the tutorials and I’m missing something because it isn’t working. I haven’t done any scripting in about a year so please bear with me.

1.) I’m trying to make the table without the data source. All of the following runs and logs fine. I don’t get any errors but nothing appears in the table. The one odd thing is that log dailyJobs doesn’t show the info being returned in the order I assumed it would be.

  1. Say I use IB to make a datasource and connect the table to the askdatasource, how does the info get into the datasource object? Do I have to code that in applescript? I’d think so. Anyway, here’s the script. Any help appreciated. I think I give up for the evening…
-- TiMat.applescript
-- TiMat

--  Created by Me on 3/13/07.
--  Copyright 2007 __MyCompanyName__. All rights reserved.

property dailyJobs : {}
property SpoilageCheck : {}
property TimeCode : {}


on clicked theObject
	if the name of theObject is "AddButton" then
		tell window of theObject
			if the state of button "OTButton" is 0 then
				set TimeCode to "RT"
			else
				set TimeCode to "OT"
			end if
			
			log TimeCode
			
			if the state of button "SpoilageButton" is 1 then
				set SpoilageCheck to "SPOILAGE"
			else
				set SpoilageCheck to "NOT SPOILAGE"
			end if
			
			log SpoilageCheck
			
			set dailyJobs to dailyJobs & {my getJobInfo(window of theObject)}
			log dailyJobs
			
			tell table view "JobsTable" of scroll view "JobsTable" to update
			
			set contents of text view "NotesField" of scroll view "NotesField" to ""
			
		end tell
	end if
end clicked





--get the values from the text fields

on getJobInfo(theWindow)
	tell theWindow
		return {jobnumber:contents of text field "JobNumField", clientname:contents of text field "ClientNameField", timeworked:contents of text field "TimeField", matused:contents of text field "MaterialAmountField", jnotes:contents of text view "NotesField" of scroll view "NotesField", MatKind:title of current menu item of popup button "MaterialPopUp", spoilage:SpoilageCheck, OTRT:TimeCode}
	end tell
end getJobInfo


Aa :confused:

Model: macbook
AppleScript: xcode 2.2.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Nobody, huh? Good thing they still make books these days. Went out and found a book called Sams Teach Yourself Applescript in 24hrs. Very good tutorials on creating tables using Applescript Studio.

Aa :confused:

So now the question is: The script has an example of setting a text item by connecting the popup to the text field. This no longer seems to work… I it take that feature was removed? The result I get is that the text field is changed to “1” upon selecting a menu item.

How come background color in a table doesn’t udpate? I mean, the background color goes to white with some cells when I select in the table when I chose to enable the alternating colors option in IB. Anyway, I have one more question (for the moment) I hope someone with all the knowledge in the universe will answer: I need a scheme for enabling checkboxes in the table. Well, more specifically I need to check the state of check box on the window, then translate that to a word other than “true” or “false” in the table, and I also need to set the check box to the correct state based on the selection of the table.

If you’re as clueless about applescript and xcode as I am I can’t recommend “Sams teach yourself Applescript in 24hrs” enough. I started with chapter 14 and while I can’t generate a complex table from scratch (yet) it showed me more than I imagined and I’ve been able to modify and (understand almost) all of the table w/data source example that Apple provides. The only negative is that the book states you can download the complex table project from the website and I wasn’t able to find that particular tutorial; I only found an archive w/lessons 14,15,16, and 18.

Aa :confused:

So, after discovering that my table doesn’t keep it’s values when I quit the application, I decided to try the document based solution. I made a new document based project and copy/pasted everything thinking it’d still work. Nope. So can someone help me understand why the on clicked function stopped working and gives the following error. I copy/pasted all the code into the document.applescript


on clicked theObject
	set theWindow to window of theObject
	if name of theObject is equal to "add" then
		-- Add a new contact
		set theRow to make new data row at the end of the data rows of contactsDataSource
		getContactInfo(window of theObject, theRow)

I get the following error:
“Can’t make end of {} into type <>. (-1700)”

Does this mean the datasource isn’t being set for the window?

tia,
Aa :frowning: