gkjpettet / objoscript Goto Github PK
View Code? Open in Web Editor NEWA dynamic stack-based VM language written in Xojo.
License: MIT License
A dynamic stack-based VM language written in Xojo.
License: MIT License
It would be nifty to be able to sort a list using a function.
Say you have a file containing:
The
quick
brown
fox
jumped
over
the
lazy
dog
When looping thru a readlines generated list, as the code current stands, will render:
The
quick
brown
foxjumpedover
the lazydog
when...
The
quick
brown
fox
jumped
over
the
lazy
dog
is expected.
The changes to the function as below, rectify the issue on all instances containing multiple EndofLines.
Thank you!
`Protected Sub ReadLines(vm As ObjoScript.VM)
/// Returns a list where each item is a line in the file.
///
/// FSItem.readLines() -> List
Var file As ObjoScript.Instance = vm.GetSlotValue(0)
// Error checks.
If file.ForeignData = Nil Or FolderItem(file.ForeignData).Exists = False Then
vm.Error("The file does not exist.")
ElseIf FolderItem(file.ForeignData).IsFolder Then
vm.Error("Cannot read lines from a folder.")
ElseIf Not FolderItem(file.ForeignData).IsReadable Then
vm.Error("Cannot read file.")
End If
Var tin As TextInputStream
tin = TextInputStream.Open(file.ForeignData)
Var lines() As String
try
var tContent as String = tin.ReadAll().ReplaceLineEndings(EndOfLine).ReplaceAll(EndOfLine + EndOfLine, EndOfLine)
While tContent.IndexOf(EndOfLine + EndOfLine) <> - 1
//recursion
tContent = tContent.ReplaceAll(EndOfLine + EndOfLine, EndOfLine)
wend
lines = tContent.Split(EndOfLine)
Catch e As RuntimeException
vm.Error("An error occurred whilst reading the file: " + e.Message + "
.")
Finally
tin.Close
End Try
vm.SetReturn(vm.NewList(lines))
End Sub`
I wrapped the function with code tags, but GitHub fails to 'code' block the entire function
var n = 10
System.print(1..n-1)
In the code above, the AST generated is wrong. It is being parsed as (1..n) instead of 1..(n-1)
KeyValue
is already a core class. Add a way to create these classes quickly with a literal.
Multiple nested if...else if
statements are not fun. Implement a switch
statement.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.