-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb85864
commit 74751be
Showing
11 changed files
with
728 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// | ||
// This little app calculates the range of a car in mpg, | ||
// "miles per gallon", based on the distance driven and | ||
// the number of gallons of gasoline used. | ||
// | ||
|
||
kAppName := "MPG:WONKO"; | ||
kAppSymbol := '|MPG:WONKO|; | ||
kAppLabel := "MPG"; | ||
|
||
// The main form can be moved around the screen | ||
newt.theForm := { | ||
viewBounds: { | ||
left: 0, top: 30, right: 180, bottom: 220 | ||
}, | ||
_proto: protoFloatNGo, | ||
recalculateMileage: func() | ||
begin | ||
local trip := wTrip.value; | ||
local gas := wGas.value; | ||
local mileage := 999; | ||
if gas > 0 then | ||
mileage := trip / gas; | ||
SetValue( wMileage, 'value, floor( mileage) ); | ||
end | ||
}; | ||
|
||
// Give the app a little title bar | ||
wTitle := { | ||
_proto: protoStaticText, | ||
text: "MPG", | ||
viewBounds: { | ||
left: 61, top: 3, bottom: 22, right: 112 | ||
}, | ||
viewFont: ROM_fontSystem12Bold | ||
}; | ||
AddStepForm( newt.theForm, wTitle); | ||
StepDeclare( newt.theForm, wTitle, 'wTitle); | ||
|
||
// I want a headline, too | ||
wHeadline := { | ||
_proto: protoStaticText, | ||
text: "calculate your gas milage", | ||
viewBounds: { | ||
left: 11, top: 22, bottom: 41, right: 163 | ||
}, | ||
viewFont: ROM_fontSystem10Bold | ||
}; | ||
AddStepForm( newt.theForm, wHeadline); | ||
StepDeclare( newt.theForm, wHeadline, 'wHeadline); | ||
|
||
// Just because we can, here is a badly drawn icon | ||
wIcon := { | ||
viewClass: clPictureView, | ||
viewFlags: vVisible, | ||
viewFormat: vfFillWhite, | ||
viewJustify: vjCenterV + vjCenterH, | ||
icon: MakeIconFromFile("embedded:/mpg.png"), | ||
viewBounds: { | ||
left: 30, top: 88, bottom: 121, right: 64 | ||
} | ||
}; | ||
AddStepForm( newt.theForm, wIcon); | ||
StepDeclare( newt.theForm, wIcon, 'wIcon); | ||
|
||
// Trip distance in miles since last fill up | ||
wTrip := { | ||
_proto: protoNumberPicker, | ||
preallocatedContext: 'wTrip, | ||
value: 0, | ||
maxValue: 9999, | ||
minValue: 0, | ||
viewBounds: { | ||
left: 51, top: 50, bottom: 81, right: 140 | ||
}, | ||
ClickDone: func() | ||
begin | ||
:recalculateMileage(); | ||
end | ||
}; | ||
AddStepForm( newt.theForm, wTrip); | ||
StepDeclare( newt.theForm, wTrip, 'wTrip); | ||
|
||
// Amount of gasoline needed after trip for a complete refill | ||
wGas := { | ||
_proto: protoNumberPicker, | ||
value: 0, | ||
maxValue: 999, | ||
minValue: 0, | ||
viewBounds: { | ||
left: 73, top: 90, bottom: 121, right: 140 | ||
}, | ||
ClickDone: func() | ||
begin | ||
:recalculateMileage(); | ||
end | ||
}; | ||
AddStepForm( newt.theForm, wGas); | ||
StepDeclare( newt.theForm, wGas, 'wGas); | ||
|
||
// Show the miles of range per gallon of gasoline used | ||
wMileage := { | ||
_proto: protoNumberPicker, | ||
value: 999, | ||
maxValue: 999, | ||
minValue: 0, | ||
viewBounds: { | ||
left: 73, top: 130, bottom: 161, right: 140 | ||
} | ||
}; | ||
AddStepForm( newt.theForm, wMileage); | ||
StepDeclare( newt.theForm, wMileage, 'wMileage); | ||
|
||
wTripLabel := { | ||
_proto: protoStaticText, | ||
text: "mi", | ||
viewBounds: { | ||
left: 142, top: 62, bottom: 80, right: 166 | ||
} | ||
}; | ||
AddStepForm( newt.theForm, wTripLabel); | ||
StepDeclare( newt.theForm, wTripLabel, 'wTripLabel); | ||
|
||
wGasLabel := { | ||
_proto: protoStaticText, | ||
text: "gal", | ||
viewBounds: { | ||
left: 142, top: 101, bottom: 120, right: 166 | ||
} | ||
}; | ||
AddStepForm( newt.theForm, wGasLabel); | ||
StepDeclare( newt.theForm, wGasLabel, 'wGasLabel); | ||
|
||
wMileageLabel := { | ||
_proto: protoStaticText, | ||
text: "mpg", | ||
viewBounds: { | ||
left: 142, top: 141, bottom: 161, right: 168 | ||
} | ||
}; | ||
AddStepForm( newt.theForm, wMileageLabel); | ||
StepDeclare( newt.theForm, wMileageLabel, 'wMileageLabel); | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<html> | ||
<body> | ||
|
||
<h1>NewtonScript Extensions</h1> | ||
|
||
<h2>Globals</h2> | ||
|
||
<b>MakeBinaryFromString(str, sym)</b>: Generate a binary object from an ASCII string. | ||
<br> | ||
<b>MakeBinaryFromARM(ARM_Instructions)</b>: Generate a binary function from ARM assembler text. | ||
Lines should be separated with \n characters. | ||
<br> | ||
<b>MakeBinaryFromARMFile(ARM_Assembler_Filename)</b>: | ||
<br> | ||
<b>PatchFileFromARM(ARM_Instructions, filename)</b>: | ||
<br> | ||
<b>AddStepForm(mainView, scrollClipper)</b>: | ||
<br> | ||
StepDeclare(mainView, scrollClipper, 'scrollClipper)</b>: | ||
<br> | ||
<b>_STDERR_</b>: | ||
<br> | ||
<b>_STDOUT_</b>: | ||
|
||
<h2>FLTK extensions</h2> | ||
|
||
<b>fltk:message(message)</b>: Open a message dialog box. | ||
<br> | ||
<b>fltk:choice(message, cancel_button, ok_button, opt_button)</b>: | ||
Open a user choice dialog box and return the selected button id. | ||
<br> | ||
<b>fltk:filechooser(message, pattern, filename, relative)</b>: | ||
Open a file chooser dialog. Returns filename or NIL. | ||
<br> | ||
|
||
<h2>Host File Access extensions</h2> | ||
<b>file:new()</b>: Create a frame to access files on the host machine. | ||
<br> | ||
<b>file:open(filename, mode)</b>: Open a file, mode is 'read|'write|'readwrite|'append. | ||
<br> | ||
<b>file:isOpen()</b>: Returns nil or true. | ||
<br> | ||
<b>file:size()</b>: Returns file size in bytes. | ||
<br> | ||
<b>file:read(size)</b>: Read up to size bytes and return a binary object with the data. | ||
<br> | ||
<b>file:write(binaryObject)</b>: Write the content of a binary object to a file. | ||
<br> | ||
<b>file:seek(pos, mode)</b>: Set read position, mode is 'set|'cur|'end. | ||
<br> | ||
<b>file:tell()</b>: Return the current read position in the file. | ||
<br> | ||
<b>file:close()</b>: Closes a file, returns exception or true. | ||
<br> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.