What old language is this? - programming-languages

A friend of mine sended bunch of code for me to build a software. However, I do not recognize language and my friend is no coder. One thing I'm sure about though. The code is something like 20-40 years old.
Code was originally used in electrical works.
Character limit per line seems to be 20 characters.
Can someone recognize this language? I'm also looking for manuals for this language if possible.
10:"K": PAUSE "IK":
CLEAR
15:P=1: INPUT "ETR=PRIN
T, 0=NO? ";P
20:DIM L(20),R(20),X(20
),B(1),G(1),Q(1),O$(
1)*24
22:IF P=1 INPUT "K. /DA
TE? ";O$(0)
24:IF P=0 GOTO 30
26:INPUT "N:0 AND NAME?
"; O$(1)
28:LPRINT O$(1): LPRINT
"KKS/";OS(0)
30:INPUT "(KVA)? ";S
35:IF P=1 LPRINT "KVA",
S
40:R=3.31 :Z=4
...
I searched for this language and PowerBasic seems to be close to it, but it contains many other features what this code lacks. Any guesses?
Edit 1
It seems that there were typos. No wonder "P=!" or "0$(0) didn't make any sense.
Edit 2
I accepted Gaby's answer because code seems to be very close to GW-Basic. Also found a manual for the language which works perfectly: http://www.antonis.de/qbebooks/gwbasman/
Thanks for the help!
Edit 3
Got some new information. Language might actually be something called "Nova Basic" from 1975. I'm unable to find manual for that language, but at least this gives me a new direction.

It's definitely a BASIC variant, one of those like in the early micro-computer days, before things like VB and structured coding came into play :-)
However, it has a few non-recognisable aspects such as:
the statement "K".
the assignment P=!, unless that ! should be a 1.
the use of variables starting with a numeric: 0$(0), unless you've mistakenly typed an O (owe) in as a 0 (zero).
None of those were very common in BASICs of the day though keep in mind the language wasn't standardised to the same level as something like C is nowadays. Everything else seems pretty standard: input, printing, assignment, array dimensioning, and so on.
Given the line length limit, the domain (KKS and KVA are both electrical terms) and the weird syntax variations, I'd say it was for one of the early programmable calculators, such as Casio, Texas Instruments or Sharp (though not necessarily those specific brands).

It reminds me of GW-BASIC
Example code at http://fr.wikipedia.org/wiki/GW-BASIC

Not a lot information in your code. Maybe QBASIC ? http://fr.wikipedia.org/wiki/QBasic

Related

Sublime Text 3 custom syntax for cottle: hard to start

I'm trying to make a "very simple" syntax highlight for "cottle" (which is a script language used in a text-to-speech app dedicated to Elite:Dangerous).
All i want (at least at the beginning) is to have three different colours: Comments, "non-strings", and strings.
I started trying with the ST3 wiki, youtube tutorials, questions here.... but i can't sort out how to do it, 'cause the way the language work.
I'll try to show you an example
{ everything_between_a_pair_of_brackets_is_code }
everything outside all pairs of bracket is a string {_ and this is a comment. It begins with "_" and ends at the closing bracket }
{ This_is_code("but this is a string")
This_is_still_code("this is also a string {but_this_is_code(\"and a string\")} and this the end of the string")
}
My problem is how to define this kind of "nidification" in my cottle.sublime-syntax file. I managed to get the comment, but only the first one.
- EDIT -
This is a real script:
{event.item}
{if event.repairedfully:
fully repaired
|else:
partially repaired
{Occasionally(2,
cat(
OneOf("to ", "at "),
Humanise(event.health * 100),
" percent functionality"
)
)}
}
{Occasionally(2,
cat(OneOf(", ", "and is"), " ready for re-activation")
)}.
The output of this script could be "Engine module fully repaired." or "Engine module partially repaired, and is ready for re-activation."
Please note the last dot of the phrase, which in the code is after the last bracket.
This is another sample, with strings passed to functions inside other strings:
{OneOf("{ShipName()} has", "")}
{OneOf("left supercruise", "{OneOf(\"entered\", \"returned to\", \"dropped to\")} normal space")}
My question is:
how sublime-syntax files handle this kind of nidification?
Looking at the overview of the templating language over at https://cottle.readthedocs.io/en/stable/page/01-overview.html, it seems to be an easy syntax for which to write a .sublime-syntax for, but given the utter lack of resources for knowing how syntax files works in ST, I can understand it can be sometimes difficult to start or even understand.
So, I took the liberty of creating a starter syntax definition (the result of an hour & a half of boredom on a Saturday evening), which you can take and work upon. Note that I have not used the language and as such made it by just reading the docs and looking over code snippets.
You can find a gist for it here (https://gist.github.com/Ultra-Instinct-05/96fa99e1aaeb32b12d1e62109d61fcc2)
Here is a screenshot showing it in the color scheme I use (which follows the official scope naming guidelines).
It still lacks support for user defined functions (as I came to know from the docs) (and probably a few other things), but maybe that's something you can add to it !
Note that to use it, save the file as Cottle.sublime-syntax in your User package. Right now files having a .cottle extension are highlighted (because I don't know how you create a cottle file).
The syntax definition doesn't use any new feature added in ST4, so it should work the same in both ST3 & ST4.

Creating Sublime Text 3 syntax for obscure language

There's a coding language called SugarCube designed for use in the Twine engine, which is used for text adventure games. Here's the Documentation for it. I'm not exactly an experienced coder - all I have is a few months in C# making a game in Unity - but I'd like to help a friend with his game, and hopefully writing his code in an editor instead of plaintext will help.
The only kind of code that matters is all marked with double angle brackets. Variables are marked with dollar signs $exampleVarand are declared and assigned using
<<set $exampleVar = "foo">>.
If and switch statements use closing tags similar to HTML:
<<if $exampleVar == "foo">>
// code
<</if>>
or
<<switch $exampleVar>>
<<case "foo">>
// code
<</switch>>
The guides I've found for custom syntax (including official documentation) are either outdated or assume you already know everything about YAML, which I don't. Advice?

tool to convert pre-cordinated SNOMED to post-coordinated

I have typed into the international Snomed browser tool `Superficial injury of head" to which I get the following -
http://browser.ihtsdotools.org/?perspective=full&conceptId1=283025007&edition=en-edition&release=v20170131&server=http://browser.ihtsdotools.org/api/snomed&langRefset=900000000000509007
or rather the important details:
Pre-coordinated:
283025007 |Superficial injury of head (disorder)|
*Post-coordinated:
82271004 |Injury of head (disorder)| +
283024006 |Superficial injury of head and neck (disorder)| :
{ 363698007 |Finding site (attribute)| = 69536005 |Head structure (body structure)|,
116676008 |Associated morphology (attribute)| = 3380003 |Superficial injury (morphologic abnormality)| }
I would find it hard to believe that the creators of SNOMED did not have a tool to take pre-coordinated exporessions and output the post-coordinated expressions.
Any SNOMED familiars happen to know of an automated way to achieve this is a tool doesn't already exist?
Thanks
I am not aware of a free online tool to do this. But what is happening is normal form generation; in your example it is giving the definition of a pre-coordinated expression but it could be taking a post-coordinated expression and generating a different normalised expression.
Without the capability of normalising an expression it is impossible to use some more advanced features of SNOMED CT, for example inheritance testing between post-coordinated expressions requires that expressions are converted into a normal form.
Having said I'm not aware of a free tool to do this, there are explicit instructions on how to do this - if you're feeling brave: https://confluence.ihtsdotools.org/display/DOCTSG/12.3.3+Building+Long+and+Short+Normal+Forms

Ternary operator should not be used on a single line in Node.js. Why?

Consider the following sample codes:
1.Sample
var IsAdminUser = (User.Privileges == AdminPrivileges)
? 'yes'
: 'no';
console.log(IsAdminUser);
2.Sample
var IsAdminUser = (User.Privileges == AdminPrivileges)?'yes': 'no';
console.log(IsAdminUser);
The 2nd sample I am very comfortable with & I code in that style, but it was told that its wrong way of doing without any supportive reasons.
Why is it recommended not to use a single line ternary operator in Node.js?
Can anyone put some light on the reason why it is so?
Advance Thanks for great help.
With all coding standards, they are generally for readability and maintainability. My guess is the author finds it more readable on separate lines. The compiler / interpreter for your language will handle it all the same. As long as you / your project have a set standard and stick to it, you'll be fine. I recommend that the standards be worked on or at least reviewed by everyone on the project before casting them in stone. I think that if you're breaking it up on separate lines like that, you may as well define an if/else conditional block and use that.
Be wary of coding standards rules that do not have a justification.
Personally, I do not like the ternary operator as it feels unnatural to me and I always have to read the line a few times to understand what it's doing. I find separate if/else blocks easier for me to read. Personal preference of course.
It is in fact wrong to put the ? on a new line; even though it doesn’t hurt in practice.
The reason is a JS feature called “Automatic Semicolon Insertion”. When a var statement ends with a newline (without a trailing comma, which would indicate that more declarations are to follow), your JS interpreter should automatically insert a semicolon.
This semicolon would have the effect that IsAdminUser is assigned a boolean value (namely the result of User.Privileges == AdminPrivileges). After that, a new (invalid) expression would start with the question mark of what you think is a ternary operator.
As mentioned, most JS interpreters are smart enough to recognize that you have a newline where you shouldn’t have one, and implicitely fix your ternary operator. And, when minifying your script, the newline is removed anyway.
So, no problem in practice, but you’re relying on an implicit fix of common JS engines. It’s better to write the ternary operator like this:
var foo = bar ? "yes" : "no";
Or, for larger expressions:
var foo = bar ?
"The operation was successful" : "The operation has failed.";
Or even:
var foo = bar ?
"Congratulations, the operation was a total success!" :
"Oh, no! The operation has horribly failed!";
I completely disagree with the person who made this recommendation. The ternary operator is a standard feature of all 'C' style languages (C,C++,Java,C#,Javascript etc.), and most developers who code in these languages are completely comfortable with the single line version.
The first version just looks weird to me. If I was maintaining code and saw this, I would correct it back to a single line.
If you want verbose, use if-else. If you want neat and compact use a ternary.
My guess is the person who made this recommendation simply wasn't very familiar with the operator, so found it confusing.
Because it's easier on the eye and easier to read. It's much easier to see what your first snippet is doing at a glance - I don't even have to read to the end of a line. I can simply look at one spot and immediately know what values IsAdminUser will have for what conditions. Much the same reason as why you wouldn't write an entire if/else block on one line.
Remember that these are style conventions and are not necessarily backed up by objective (or technical) reasoning.
The reason for having ? and : on separate lines is so that it's easier to figure out what changed if your source control has a line-by-line comparison.
If you've just changed the stuff between the ? and : and everything is on a single line, the entire line can be marked as changed (based on your comparison tool).

What emoticons can you put into class names in your language? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've just had a discussion with a developer about naming classes in C#. My final throw away line was, "Let's not put any emoticons in our class names."
I can't think of a way you could put emoticons in C# class names, but I haven't thought too hard about it. Is this possible?
Does any programming language allow it? What would be the best/worst language to be able to perform this in?
Update: The Scheme answer bests answers my question. It was a quick idea after a quick discussion so I'm going to accept after a short amount of time and then move on with my life. Thanks for the responses.
Many Japanese-style emoticons - O_o, v_v and the like - are perfectly legal substrings of identifier names in most languages.
For example in Scheme you have the flexibility to include symbols like :, -, / ... in the names,
(define (:-D x)
(+ x 1))
...
(:-D 9)
output: 10
C# supports any Unicode letter for identifiers, so if you find some suitable for emoticons in the Unicode tables, you can use them. The CLR itself allows far more characters in identifier names, like the typical backtick used in compiler-generated names, so you could get really crazy by defining really strange names in MSIL, and then loading the classes with reflection in C# because it does not support those characters...
The method name oO comes to mind. It's an emoticon in itself (small and large eye), but when called on a reference, it expands to a thought bubble: .oO(Hello).
Slightly off-topic: I was processing filenames the other day and realised that all sorts of faces had appeared in my code:
string number(fn.begin()+fn.rfind('_')+1,fn.begin()+fn.rfind('.'));
And of course there are the right-to-left emoticons you almost always get at the end of lines of C++ code:
mesh->Delete();
Why does C++ look so sad?
In C++, if you name a class/struct _ (a poor decision, but here we go), you can derive from it like this:
struct emoticon_to_the_right_of_this :_{
};
Thinking about this, a class o might be just as good:
struct another_emoticon_to_the_right_of_this :o{
};
Hm. I seem to only come up with sad ones. Is that Freud guy around here today? I do have a question to ask him...
Perl uses :: as a package name separator, which means that an IM client might decide to insert a smiley when I talk about XML::Parser (contains ":P") or Data::Dumper (contains ":D"). Punctuation other than :: isn't recommended in package names, so most "extended" smileys are out of the picture, but if I wanted to be very silly I could reference a variable named ${ ':-)' } -- but it would always have to be referenced using the ${'...'} syntax since it's not a recognizable identifier name :)
At this moment in 2014, Apple have just released Swift yesterday. And I made a short example for this. It compiles and runs perfectly fine. :D
I believe I've seen languages that use => to access object attributes (something like person=>father)
It's not actually part of the name, but it could be an emoticon.
Not strictly class names, but there are a few that pop up in PHP from time to time, like an underscore in single quote when concatenating:
$foo = $bar.'_'.$baz;
And as someone else pointed out, you don't even really need special symbols for some of them:
class o_0 {}
class v_v {}
class T_T {}
Something more convoluted:
function d() { echo 'Thumbs up!!'; }
d('_');

Resources