// Text of project ADSPSample written on 5/9/95 at 12:16 PM // Beginning of file Configure.t floatBaseView := {viewBounds: {left: 0, top: 46, right: 228, bottom: 194}, viewSetupFormScript: func() begin addressData := GetRoot().(kAppSymbol).LiveRemoteAddress.data.addressData; // Start munging so the stuff looks real // First the zone. local pos := StrPos(addressData, "@", 0); ADSPZone := SubStr(addressData, pos+1, 32); // Then the name. local pos2 := StrPos(addressData, ":", 0); ADSPName := SubStr(addressData, 0, pos2); // Finally the type ADSPType := SubStr(addressData, pos2 + 1, pos - pos2 - 1); end, ADSPName: nil, ADSPType: nil, ADSPZone: nil, viewQuitScript: func() begin // Update the address info in the app base view. GetRoot().(kAppSymbol).LiveRemoteAddress.data.addressData := Stringer([ADSPName, ":", ADSPType, "@", ADSPZone]); end, debug: "floatBaseView", _proto: @180 }; mainLabel := {text: "ADSP Server Address", viewBounds: {left: 8, top: 8, right: 224, bottom: 32}, viewJustify: 8388610 , debug: "mainLabel", _proto: @218 }; AddStepForm(floatBaseView, mainLabel); NameInput := {viewBounds: {left: 0, top: 40, right: 224, bottom: 64}, label: "Server Name:", textSetup: func() begin // Return the ADSP name stored in the parent view for default setup. return ADSPName; end, textChanged: func() begin // We did something with the values, update parent. ADSPName := entryline.text; end, debug: "NameInput", _proto: @189 }; AddStepForm(floatBaseView, NameInput); StepDeclare(floatBaseView, NameInput, 'NameInput); TypeInput := {viewBounds: {left: 0, top: 72, right: 224, bottom: 96}, label: "Server Type:", textSetup: func() begin // Return the ADSP Type in the parent view as the default value. return ADSPType; end, textChanged: func() begin // We did something with the values, update parent. ADSPType := entryline.text; end, debug: "TypeInput", _proto: @189 }; AddStepForm(floatBaseView, TypeInput); StepDeclare(floatBaseView, TypeInput, 'TypeInput); ZoneInput := {viewBounds: {left: 0, top: 104, right: 224, bottom: 128}, label: "Server Zone:", textSetup: func() begin // Return the ADSP Zone string stored in the parent view as the default value. return ADSPZone; end, textChanged: func() begin // We did something with the values, update parent. ADSPZone := entryline.text; end, debug: "ZoneInput", _proto: @189 }; AddStepForm(floatBaseView, ZoneInput); StepDeclare(floatBaseView, ZoneInput, 'ZoneInput); constant |layout_Configure.t| := floatBaseView; // End of file Configure.t // Beginning of file Main.t // Before Script for "ADSPSample" /* ** Newton Developer Technical Support Sample Code ** ** ADSP Sample, a short example to show AppleTalk/ADSP communications ** ** by Jim Schram, Mike Cremer, Randy Carr, Kent Sandvik, ** ** Copyright © 1995 by Apple Computer, Inc. All rights reserved. ** ** You may incorporate this sample code into your applications without ** restriction. This sample code has been provided "AS IS" and the ** responsibility for its operation is 100% yours. You are not ** permitted to modify and redistribute the source as "DTS Sample Code." ** If you are going to re-distribute the source, we require that you ** make it clear in the source that the code was descended from ** Apple-provided sample code, but that you've made changes. */ ADSPSample := {title: "", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, InitConnection: func() begin :PutDataInStatusArea("Connecting..."); RefreshViews(); ep := {_proto: baseEndpoint, _parent: self}; // make a RAM copy so we can modify it local err := ep:Instantiate(ep, nil); if err then begin CloseAppleTalk(); :PutDataInStatusArea("Unable to initialize..."); GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Sorry, can't open AppleTalk!")); return; end; err := ep:Connect(LiveremoteAddress, nil); // always check for results from Connect if err then begin CloseAppleTalk(); :PutDataInStatusArea("Unable to connect..."); GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Couldn't connect..." & NumberStr(err))); return; end; ep.myBase := _parent; ep:SetInputSpec(ep.doInput); // set up first inputSpec :PutDataInStatusArea("Connected, waiting for disconnect..."); connected := true; end, ReleaseConnection: func() begin if connected then begin ep.nextInputSpec := nil; // no more input ep:SetInputSpec(nil); // kill the current inputSpec ep:Abort(); // asynchronously abort any pending I/O :PutDataInStatusArea("Ready to connect..."); // must use a quick little delayed action to dispose AddDelayedAction(DisposeConnection, [ep], 100); end; end, PutDataInStatusArea: func(s) begin SetValue(StatusArea, 'text, s); end, PutDataInReceivedArea: func(s) begin SetValue(ReceivedArea, 'text, s); end, viewSetupDoneScript: func() begin ActiveConnection := 0; ActiveListenConnection := 0; LiveRemoteAddress := DeepClone(remoteAddress); // clone so we could modify this one :PutDataInStatusArea("Ready to connect..."); end, SendDataInSendField: func() begin ep:Output(SendDataField.entryLine.text, kMore); ep:Output([unicodeCR, unicodeLF], nil); ep:FlushOutput(); end, connected: nil, remoteAddress: { type: 'address, label: kCMARouteLabel, opCode: opSetRequired, data : { addressType: kNamedAppleTalkAddress, addressData: "Ralph:ADSP@*" } }, baseEndpoint: { _proto: protoEndpoint, // NTK protoEndpoint configOptions: [ { label: kCMSAppleTalkID, type: 'service, opCode: opSetRequired }, { label: kCMSAppleTalkID, type: 'option, opCode: opSetRequired, data: kCMOAppleTalkADSP }, { label: kCMOEndpointName, type: 'option, opCode: opSetRequired, data: kADSPEndpoint }, ], myBase: nil, // All endpoint related exceptions end up here, catch them. exceptionHandler: func(exception) begin GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Exception: " & exception.data)); return true; end, doInput: { inputForm: 'string, endCharacter: unicodeCR, discardAfter: 200, inputScript: func(endpoint, s) begin endpoint.myBase:PutDataInStatusArea("Data received..."); endpoint.myBase:PutDataInReceivedArea(s); end, }, }, ep: nil, DisposeConnection: func(ep) begin ep:Disconnect(); ep:Dispose(); CloseAppleTalk(); GetRoot().(kAppSymbol).connected := nil; end, LiveRemoteAddress: // the ADSP address frame, in memory, so we could modify this one nil, viewQuitScript: func() begin :ReleaseConnection(); end, debug: "ADSPSample", _proto: @157 }; _view000 := {viewFlags: 1, viewFormat: 304, viewBounds: {left: 11, top: 203, right: 233, bottom: 281}, viewClass: 74 }; AddStepForm(ADSPSample, _view000); StatusArea := {text: "", viewBounds: {left: 10, top: 26, right: 232, bottom: 64}, viewJustify: 0, viewFormat: 67436880, debug: "StatusArea", _proto: @218 }; AddStepForm(ADSPSample, StatusArea); StepDeclare(ADSPSample, StatusArea, 'StatusArea); ReceivedArea := {text: "", viewBounds: {left: 10, top: 82, right: 232, bottom: 159}, viewJustify: 0, viewFormat: 67436880, debug: "ReceivedArea", _proto: @218 }; AddStepForm(ADSPSample, ReceivedArea); StepDeclare(ADSPSample, ReceivedArea, 'ReceivedArea); Status := {text: "Status", viewBounds: {left: 18, top: 18, right: 114, bottom: 34}, viewTransferMode: 0, debug: "Status", _proto: @218 }; AddStepForm(ADSPSample, Status); Received := {text: "Received Data", viewBounds: {left: 18, top: 74, right: 114, bottom: 90}, viewTransferMode: 0, debug: "Received", _proto: @218 }; AddStepForm(ADSPSample, Received); Connect := {text: "Connect", buttonClickScript: func() begin if not connected then :InitConnection(); else GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Already connected!")); end, viewBounds: {left: 12, top: 172, right: 120, bottom: 192}, debug: "Connect", _proto: @226 }; AddStepForm(ADSPSample, Connect); StepDeclare(ADSPSample, Connect, 'Connect); Disconnect := {text: "Disconnect", buttonClickScript: func() begin if connected then begin :PutDataInStatusArea("Disconnecting..."); :ReleaseConnection(); end else GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Not connected!")); end, viewBounds: {left: 132, top: 172, right: 232, bottom: 192}, debug: "Disconnect", _proto: @226 }; AddStepForm(ADSPSample, Disconnect); StepDeclare(ADSPSample, Disconnect, 'Disconnect); SendDataField := {viewBounds: {left: 18, top: 210, right: 226, bottom: 274}, viewFormat: 256, viewLineSpacing: 16, label: "Data:", textSetup: func() begin return "this is a test"; end, indent: 80, debug: "SendDataField", _proto: @189 }; AddStepForm(ADSPSample, SendDataField); StepDeclare(ADSPSample, SendDataField, 'SendDataField); SendButton := {text: "Send", buttonClickScript: func() begin if connected then :SendDataInSendField(); else GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal("Not connected!")); end, viewBounds: {left: 36, top: 292, right: 104, bottom: 312}, debug: "SendButton", _proto: @226 }; AddStepForm(ADSPSample, SendButton); StepDeclare(ADSPSample, SendButton, 'SendButton); configureButton := {text: "Configure", buttonClickScript: func() begin // Open a view that will ask for the type and name info, and the zone info as well. ConfigureView:Open(); end, viewBounds: {left: 128, top: 292, right: 196, bottom: 312}, debug: "configureButton", _proto: @226 }; AddStepForm(ADSPSample, configureButton); ConfigureView := LinkedSubview(floatBaseView, {viewBounds: {left: 6, top: 306, right: 134, bottom: 334}, debug: "ConfigureView" }); AddStepForm(ADSPSample, ConfigureView); StepDeclare(ADSPSample, ConfigureView, 'ConfigureView); // After Script for "ADSPSample" thisView := ADSPSample; thisView.title := kAppName; constant |layout_Main.t| := ADSPSample; // End of file Main.t