RetroBASIC

Basicprogramming(.org) => Tutorials and articles => Topic started by: B+ on September 20, 2018, 06:02:20 PM

Title: Notes on Script BASIC
Post by: B+ on September 20, 2018, 06:02:20 PM
Tried it once, because you know who goes on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on .... in everyone else thread except his own.

I got yelled at for not reading manual when I asked a question.

Sorry no manual was ever made available.

Who thinks I should try it again?

Title: Re: Notes on Script BASIC
Post by: B+ on September 20, 2018, 06:15:48 PM
From comments I read from other Beginners with Script BASIC, I get the impression it is NOT Beginner friendly.

I know one promoter of Script BASIC who is not friendly to Beginners but that is another story...

Maybe it should be called Script ASIC ;D
Title: Re: Notes on Script BASIC
Post by: B+ on September 20, 2018, 06:50:53 PM
Well look here,
 http://info.bannerengineering.com/cs/groups/public/documents/literature/191745.pdf
instead of yelling at people for not reading a manual, someone actually goes ahead and writes one!

Now that is watching out for Beginners.
Title: Re: Notes on Script BASIC
Post by: ScriptBasic on September 20, 2018, 06:57:21 PM
Script BASIC is probably one of the best documented non-commercial open source projects out there. Not only is there a Users Guide, the developer embedded and extension API documentation let's you morph the scripting engine into whatever you need.

If there were more project managers like me, there wouldn't be over 100 abandoned BASIC languages with efforts like yours adding new plots to the BASIC graveyard.

@B+ - You are beginning to turn into a bitter whiner and losing my respect with each new post.
Title: Re: Notes on Script BASIC
Post by: B+ on September 20, 2018, 07:14:53 PM
Quote
B+,

Tomaaz said he didn't like Script BASIC because there was no install program for Linux and was confused how to include the SB executable path or create the configuration file. I  would have been happy to help him get going if he would have asked.

What don't you like about Script BASIC?
« Last Edit: Today at 08:07:55 by John »

Asked and answered.
Title: Re: Notes on Script BASIC
Post by: ScriptBasic on September 20, 2018, 07:50:09 PM
Here is another (commercial) resource for Script BASIC to feed your bitter sweet spot.

Control Solutions MN (https://www.csimn.com/CSI_pages/softwareBasic.html). They have been using Script BASIC embedded in their BACNet controllers since 2003.
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 20, 2018, 10:43:03 PM
So, I'm an idiot who would love to use ScriptBasic, but is to stupid to start with it. Good to know.  ;D ;D ;D

John, belive me - if I really wanted to use ScriptBasic, I would manage to install and configure it. I just can't see anything what could justify using my free time do do it. For me, a serious scipting language* should out of the box come with features like proper associative arrays, sorting, filtering, applying functions to each element of an array and getting unique elements without writing FOR/NEXT loop for it. I want to have function for reading an entire text file into a string, ability to use regular expressions, recurively walking  through directories, having easy acces to a file info (basename, extension, realpath, type of the file, permissions etc.). Generic FOR loop makes things a lot cleaner and easier. Basic Internet functionality (like downloading a file) should be there. Also, support for unicode and large numbers. If I want to use Perl or JavaScript, I'm gonna use Perl or JavaScript and not ScriptBasic with Perl and JavaScript modules. Just have a look at Perl's, Python's or Ruby's standard library. Then have a look and PyPI, CPAN and Ruby Gems. Then look at ScriptBasic. Can't you see a difference?  I don't know - maybe ScriptBasic is not a bad choice for embedding, but I'm not planning to build a device that will need an embedded language to be used with it, so I don't care.

Script BASIC is probably one of the best documented non-commercial open source projects out there.

 ;D ;D ;D Comparing to what? Those 100 abandoned BASIC languages? Seriously, do you want me to die from laughing?  ;D ;D ;D

OK. Have a look at documentation pages on:

https://nim-lang.org/
https://crystal-lang.org
https://dlang.org
https://www.ruby-lang.org/en/

* Of course, languages created for fun or for specific tasks are a completely different story.
Title: Re: Notes on Script BASIC
Post by: B+ on September 20, 2018, 11:47:57 PM
You know this package looks like a decent User Manual, why not include it with SourceForge download of Script Basic?
But what is i.CanDoIt Device to practice using ScriptBasic on?

Oh it is a server $1500 to $2000 "remote monitoring solution". Just what every beginner needs.
Title: Re: Notes on Script BASIC
Post by: B+ on September 21, 2018, 02:00:29 AM
Oh I see the big ugly secret, not a screen function to be found!

No Locate, no Input, no Cls, its all a text scroller.

Finally, I get Hello World! to work:
Code: [Select]
Print "Hello World!"
sleep 100
drag and drop onto sb64.exe

So again I say, Script ASIC is a bad BASIC for Beginners, get back to your side of the pool.

https://www.youtube.com/watch?v=oEzXvP7RMaw
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 08:27:18 AM
Here is a list sequence bunch* of numbers - [120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120]. The task is to print three biggest unique elements sorted from biggest to smalllest.

Python:
Code: [Select]
x = [120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120]
print(sorted(list(set(x)), reverse=True)[0:3])

Can I see ScriptBasic solution, with its "powerfull" and "flexible" arrays?

EDIT Yes, Python lists can be nested and can hold values of different types (just in case you ask this question again).

* To make Aurel happy, I've changed it once more. ;)
Title: Re: Notes on Script BASIC
Post by: jj2007 on September 21, 2018, 12:19:11 PM
Nice that Python can handle that, but this ultra-short syntax is not necessarily good for readability. I am more comfortable with more explicit syntax:
Code: [Select]
  Dim x(11) As DWORD
  ArraySet x()=120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120
  ArraySort x(-) ; sort descending
  For_ ct=0 To x(?)-1
Print Str$(x(ct)), " "
  Next
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 01:03:47 PM
And where is the part that removes all duplicates from the array and leaves only unique elements?
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 01:20:30 PM
What you see as list is not a list than array of pointers because python don't have native built in
linked  list  :o
you probably need to use lib written in C/C++ to do that in python
I once tried ScriptBasic and never again and i have some exeperience in Basic but
this thing is not for me and i doubt that is for any begginer at all 
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 01:23:51 PM
WOW ...WOW ...
John is really quick he delete account here
geee
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 02:09:46 PM
Aurel, I've changed "list" to "sequence". Happy?  ;D You can also call it "a group", or "a bunch". I don't care, because it's clear what the task is and internal representation and handling of data in different languages has nothing to do with it.
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 02:20:37 PM
Oh boy
No is not .Sequence is something different and that is proof that you don't know the things.
In fact i am not surprised it is not the first time you like to talk about things you don't understand
..man you must know the background of stuff then you can patronize what is what and what we must do
 ;D
hmmmm tomek ..tomek...
Ok i agree with you that from ordinary perspective is not important to know
but is not bad to know because someone like you may talk from very high points ...
he he ...jibba
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 02:22:17 PM
..and what a heck script basic have with all this  ::)
Title: Re: Notes on Script BASIC
Post by: Ed Davis on September 21, 2018, 02:38:58 PM
Here is a list sequence of numbers - [120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120]. The task is to print three biggest unique elements sorted from biggest to smalllest.

Below is a C version.  I used 12 just to show that only unique entries are printed. 

This definitely shows the utility of using something like Python, Ruby, etc. 

I'm taking a C# course.  I wonder if it has any shortcuts?  e.g., I can do this in C#, the C way (e.g., old programmers joke:  I can write FORTRAN in any language), but don't yet know enough about C# to know if it has any Python-like shortcuts.

Code: [Select]
#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE(a) sizeof(a)/sizeof(a[0])

/* Comparison function. Receives two generic (void) pointers to the items under comparison. */
/* https://en.wikipedia.org/wiki/Qsort */
int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    if (x < y)
        return 1;   // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;  // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

// print first k unique entries from array ar, don't go past n
void print_unique(int ar[], int k, int n) {
    int i, last;

    for (i = 0; i < n && k > 0; ++i, --k) {
        if (i == 0 || ar[i] != last)
            printf("%d\n", ar[i]);
        last = ar[i];
    }
}

int main() {
    int ar[] = {120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120};

    qsort(ar, ARRAY_SIZE(ar), sizeof(ar[0]), compare_ints);
    print_unique(ar, 12, ARRAY_SIZE(ar));
    return 0;
}

I used gcc, but this should compile with any standard C compiler.
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 02:44:37 PM
Aurel, I don't care about this internal stuff. The whole idea of easy to use scripting languages is that you don't have to. I used Python in my example and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array". If you want to discuss this internal stuff, please register on any of Python forums and tell them to call lists "arrays" . Guido just resigned, so who knows? You even may be succesful.  ;D Just let me know where you've registered. Don't want to miss an opportunity for good laughs.  ;D

I've posted a piece of code that works and do exactly what is meant to do. And you come with some absurd arguments about it. I think it is just a desperate way to start a fight with me.  ;) And what it has to do with ScripBasic? John several times claimed that ScriptBasic arrays were more flexible and powerfull than similar data types in modern languages. I want to show you how wrong he was.
Title: Re: Notes on Script BASIC
Post by: ZXDunny on September 21, 2018, 03:12:43 PM
WOW ...WOW ...
John is really quick he delete account here
geee

I suspect it's because we're not being professional with our BASICs. In his eyes, BASIC isn't meant to be fun, it's certainly not meant to be easy to create one (even though it's pretty trivial to make a simple language interpreter) and the fact that we're having fun with ours and not pursuing a career out of it offends his delicate sensibilities :D

And goshdammit, no BASIC creators have contributed to his wiki! Heathens, the lot us.

And so he's flounced out of our little community. It's not the first time though, so I'm not overly concerned.
Title: Re: Notes on Script BASIC
Post by: B+ on September 21, 2018, 03:43:55 PM
Well I hope he quit to go put all his focus on project to make a Beginners package to prove how extensible and pluggable ScriptBasic really is. So he can get his B back from B+, I hate calling anything ASIC.

Should be a trivial thing for a professional coder, heck it might even be fun.
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 04:33:24 PM
Quote
and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array"

well that explain a lot about you   ;D
just like hole is a hole  ;D ;D ;D
oh boy oh boy....
good thing is that i am not John and also i don't care about your babeling "stupid" things .
maybe is a time for vodka  ::)
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 04:57:25 PM
Quote
and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array"

well that explain a lot about you   ;D

Can anyone explain what that explains about me?

Aurel, are you aware that "lists" doesn't neceserilly mean "linked lists"? Python, for example has lists (https://www.tutorialspoint.com/python/python_lists_data_structure.htm) that are not linked lists, but if you need linked lists you can implement them easily without using anything written in C/C++:

https://www.tutorialspoint.com/python/python_linked_lists.htm
https://medium.com/@kojinoshiba/data-structures-in-python-series-1-linked-lists-d9f848537b4d
http://interactivepython.org/courselib/static/pythonds/BasicDS/ImplementinganUnorderedListLinkedLists.html

Here is a code in NewLisp:

Code: [Select]
(set 'x '(120 135 345 345 1890 12 120 12 135 712 78 120))
(println (slice (sort(unique x) >) 0 3))

I hope that lists in NewLisp are, under the hood, implemented as linked lists*. Otherwise, you have to inform its author that he has to change the name to NewArrp.  ;D

EDIT After you've registered on some Python forum, just remember to put "https is a just another crap". It will instantly gain you some "respect". ;D ;D ;D

* I believe they are, but you have to check the manual to be 100% sure.
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 05:25:16 PM
No ..Noo ...noooooooooooo
pssssst ...so i must create LIST which is what LIST listing  >:(
in fact it is good to fool naive jer**
 ;D
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 05:28:56 PM
YO man script basic don't have LIST[]  ::)
oh poor JRS

oh sorry mister T i forget that you know everything  :P
Title: Re: Notes on Script BASIC
Post by: AlyssonR on September 21, 2018, 06:05:27 PM
No matter what you say ... Script Basic is a decent program - and like any, it has pluses and it has minuses.

It is *not* the easiest version of BASIC to use, but it is quick and clean and is well suited to providing back-end services (especially if you want to be able to connect to a diagnostic socket using a terminal program).

For business-style front ends, I still think that VB6 is as good as it gets - which is a shame, because there are so many cool looking user interfaces that can be build elsewhere - but at the cost of a rat's nest of programming because you need to re-create the wheel for every widget, whatsit and whistle.

Now, if someone could come up with a (cross-platform) graphical terminal program (they used to be called graphics terminals) that allowed a form to be generated from a configuration file, using skinnable widgets and complete with all of the event messages and data interchange over a serial connection, then I'd probably pay money for it.
Title: Re: Notes on Script BASIC
Post by: Peter on September 21, 2018, 08:42:54 PM
Hi Tomaaz,

Well, that is a naughty thing to do, challenging BASIC with a construct which is the very essence of some other programming language ;). As you know, Lisp, or LISt Processing, was designed to process lists. No wonder that a list can be processed in such an elegant way in newLisp. List processing is of course not the strongest skill of a BASIC language.

And I understand your reaction, it actually made me laugh :) Still, I keep using my converter, but this is with a reason. After I had used ScriptBasic for a while, I discovered newLisp and I started to program it fanatically (see some programs here (http://www.turtle.dds.nl/newlisp/index.html)). I used to be very good at it (http://www.turtle.dds.nl/gl4newlisp/index.html), if you don't mind me saying. If you look into the archives of the newLisp forums, you'll see a lot of my posts. I also posted a lot of issues and bugs in the language (for example here (http://www.newlispfanclub.alh.net/forum/viewtopic.php?p=8302#p8302)). I liked the language so much that I actually met the newLisp creator Lutz Mueller in person.

However, I did leave newLisp, for a couple of reasons, even though newLisp can process a list very good as well as it can do some other things very good. Your code snippet looks nice and small, but there are other aspects to newLisp which, at a certain point in time, can be a disadvantage. To name a few:
You mentioned some requirements (http://retrogamecoding.org/board/index.php?topic=705.msg5441#msg5441), but here are mine: I left newLisp because I needed to create genuine binaries optimized for speed, independent from interpreters or other persons, without the option of 3rd parties peeking inside my code, and sought for a compatible (meaning multi-platform Unix oriented) way to do this. I ended up implementing a kind of a C preprocessor, using a syntax loosely based on VIC-20 BASIC and ScriptBasic, because I am a nostalgic person. This is the Basic Converter (http://www.basic-converter.org/) project.

Surely, it is not The Best Thing For All Purposes, but it fills my needs. And even though I may have to use a FOR/NEXT and a SORT to accomplish your task, at least I can create a program which performs such task very fast, independent from interpreters and libraries and other persons, in a readable manner, producing a binary which cannot be peeked into, executable on all POSIX platforms, even on my Android phone. Which you cannot say about newLisp (nor ScriptBasic) :P

This would be a solution in BaCon:

Code: [Select]
SPLIT UNIQ$("120 135 345 345 1890 12 120 12 135 712 78 120") TO list$ SIZE t
MAP list$ BY VAL TO nr SIZE t
SORT nr SIZE t DOWN
PRINT nr[0], " ", nr[1], " ", nr[2]

Not even a FOR/NEXT required  :)

Best regards,
Peter
Title: Re: Notes on Script BASIC
Post by: Aurel on September 21, 2018, 09:10:26 PM
Peter
Tomaaz patronize to me about Python and not about newLips
and i doubt that he know how to make programs in newLisp or any other Lisp-Scheme etc PL-s  ::)
(copy/paste examples is his way just to show off....
Script Basic primary thing is as far as i know server-side scripting is it?
so as such this language is not for most hobby -enthusiast etc programmers
and also primary target is Linux.
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 21, 2018, 11:06:43 PM
Peter, thanx for an interesting post and your solution in BaCon!

What I like about NewLisp is its simplicity, nice set of built-in functions and good documentation. However, I'm not 100% happy with it. The most important reason is its performance. Sometimes, NewLisp is surprisingly slow. I'm also not the biggest fan of Java-based GUI. To be honest I think that even Tk would be a better option and I don't understand why it's been swapped for Java. Recently, a new version of NewLisp has been released. I need to have a look at it again and force myself to think in a functional style, because my NewLisp coding was to procedural, I'm afraid. To be honest, the only reason I've mentioned NewLisp here was to have a laugh at Aurel's nonsensical "linked lists" argument (glad it made you laugh. ;)) My main example is in Python and it's been posted to show ScriptBasic's weakness rather than to promote Python itself. Unfortunately, if Python is mentioned anywhere on this forum then you can be 100% sure that Aurel will arrive ASAP with his WinApi, anti-OOP and vodka arguments.  ;)

I wonder what's your opinion on ScriptBasic. You've mentioned that you used it for some time. You're a top BASIC developer and user, so it would be very interesting to hear what you think about that interpreter.

Tomaaz patronize to me about Python and not about newLips

 ;D ;D ;D Lips, python... Sigmund Freud would have had something to say about your case. Then, of course, there is "the pipe" and Tux the Linux mascot...  No, I don't even want to think about it!!!  :o :o :o
Title: Re: Notes on Script BASIC
Post by: Peter on September 22, 2018, 08:53:01 AM
Ha ha, you do have quite a sense of humor I must say :) Regarding ScriptBasic, it is a good BASIC with some interesting features, but from my point of view, it has similar issues as encountered in newLisp:
As for the newLisp GUI, I also was disappointed that it started to use a Java-based GUI, a decision made some time ago. I am not saying that it should have been GTK, but come on... Java?!?! Really?!?!  ???  Even if this would be the last graphical toolkit in the world, I would not remotely consider using it because of its huge and clumsy install base - as a matter of fact, I would rather optimize my text based editor and render my code in ASCII using ANSI escape codes (https://en.wikipedia.org/wiki/ANSI_escape_code) and UTF8 based character sets to draw lines (https://en.wikipedia.org/wiki/Box-drawing_character) thereby simulating a window layout (like the DOS based Visual Basic 3.0, or Turbo Pascal).

Regards
Peter
Title: Re: Notes on Script BASIC
Post by: Aurel on September 22, 2018, 11:03:43 AM
The old story  :)
Tomas loves to convey himself as an expert for every programming language
and in fact he is a common miser who thinks he knows something.

oups he is very good copy/paste programmer. ;D ;D ;D
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 22, 2018, 01:19:33 PM
  • ScriptBasic's current state: it is not actively being maintained anymore by the original developer, Peter Verhas, whose presence in the project would guarantee a high quality implementation

For me, that's the main issue. ScriptBasic seems unfinished. John is doing good job, but it's not a replacement for a proper development.

As for the newLisp GUI, I also was disappointed that it started to use a Java-based GUI, a decision made some time ago. I am not saying that it should have been GTK, but come on... Java?!?! Really?!?!  ??? 

Good to know it's not only me.  ;)

The old story  :)
Tomas loves to convey himself as an expert for every programming language
and in fact he is a common miser who thinks he knows something.

Considering the fact that I've just admitted my Lisp skills being rather poor, what are you talking about? For your information:

Please, update your database and next time, when you want to say something about me, use an up to date information (and a correct spelling of my name). Also, you forgot to mention two other things I'm very good at - configuring Geany and heavy vodka drinking.  ;D
Title: Re: Notes on Script BASIC
Post by: B+ on September 22, 2018, 02:19:36 PM
Uh! because Script ASIC doesn't structure variables the same as other PL's doesn't mean it couldn't produce same results in one elegant line, just needs some setup.

For example QB64 has next to nothing for array handling, I had to build a library just to sort an array of floats and some other tools for handling number arrays but I had all tools to make a function that does same as these built-ins of PL's you are showing off.

Code: [Select]
'Test Floats Array Tools Library.bas for QB64
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "descend", 0, 3) 'Tomaaz sample
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "ascend", -10, 5) 'test join tolerance
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "descend", 3, 16)
PRINT UniqueSortSlice$("1 1.1 1.11 1.1 1.11 1. 1.0 1.111 .999999999999999999999999999999999999999", "ascend", 0, 1000) 'oh that's nice!!! but I think .99... is same as 1

FUNCTION UniqueSortSlice$ (NumberStr$, ascendDescend$, SliceStart AS LONG, SliceEnd AS LONG)
    REDIM temp(0) AS _FLOAT
    Split2Floats NumberStr$, " ", temp()
    uniqueFloats temp()
    qSortFloats LBOUND(temp), UBOUND(temp), temp()
    IF ascendDescend$ <> "ascend" THEN reverseFloats temp()
    UniqueSortSlice$ = JoinFloats$(temp(), SliceStart, SliceEnd, " ")
END FUNCTION

'$include: 'Floats Array Tools.bm'

See attached output. It would have been easier with Script Basic or with SmallBASIC because both use variant variable types and more advanced array stuff is already built into language.


Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 22, 2018, 02:39:47 PM
Well, if you build yourself a special library dedicated to that task then you can have a one-liner in any language, but that's not the point. The point is that in Python things like that are ready to use out of the box. That was just a very basic example. You can create more complex examples and then what? Are you gonna create a special library for each of them?

Title: Re: Notes on Script BASIC
Post by: B+ on September 22, 2018, 02:42:55 PM
I built a special library to handle float arrays the same as you are showing, as strings$

I did build a special function because QB64 sucks as far as not being able to pass arrays through functions, not same problem with Script or SmallBASIC.

How hard is it to change your output to this? (attached)

And how do these things handle floats? The forth line? I am curious the decision it would make for 1, 1.0, 1. and .99.... would they be the same or each unique?



Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 22, 2018, 03:48:49 PM
OK. Here is another task. Recursively walk directory, find all .jpg files which names are integers, sort the names by numbers and print the result.

Ruby (one line):
Code: [Select]
puts Dir.glob("**/*").select{|a| File.extname(a) == ".jpg" and File.basename(a, ".jpg").to_i.to_s == File.basename(a, ".jpg")}.map {|a| File.basename(a, ".jpg").to_i}.sort

If you want to know what part of the code is responsible for what part of the task, I can explain it to you. It only looks cryptic. If you know basics of Ruby it's clear as
Code: [Select]
for x = 1 to 10 : print x : next x in BASIC.  ;)
Title: Re: Notes on Script BASIC
Post by: Mike Lobanovsky on September 22, 2018, 07:58:01 PM
Look guys,

What are those Python/Ruby/QB64/younameit "tasks" doing in the Notes on Script BASIC thread in the absence of the language project lead?

Is the forum Administration really after the ever increasing message counter readings by way of blatant trolling and flooding in every other thread on a BASIC forum?!

(Tomaaz, should BASICs be able to swallow LISP-ish lists and maps, they would've been called LISPs. Or Pythons at the worst. This is definitely not what the BASIC community is particularly after -- here or elsewhere.)
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 22, 2018, 09:58:39 PM
Mike, you were away writing next "Smoke on The Water" or next "Child in Time", so let me explain what's happened here. John kept spamming every possible topic and asking me and B+ what was that we didn't like about ScriptBasic. In response to that, B+ has started this topic and we have both given John our answers. B+ doesn't like the fact that ScriptBasic is not beginner friendly, I don't like the fact that it's unfinished and, despite what John's saying, it can't compete with serious scripting languages (my examples are here to prove it). John, instead of agreeing/disagreeing with us, has closed his account. I agree that there was "trolling and flooding in every other thread", but, sorry, it wasn't me or B+.

As for "lists and maps", they are part of any serious scripting language. You can find them in Python, Perl, Ruby, Tcl, PHP, JavaScript. Does it make Perl Python? Should we call Ruby "PHP"? Or maybe we should call PHP "Ruby"? How come NewLisp looks completely different than Tcl? They both have "lists and maps". For me, BASIC doesn't have to have these features. It would be nice if it had, but it's not necessary. After all, BASIC is meant to be a simple language for beginners. You just need to understand that it's not as powerful and flexible language as Python, Ruby or Perl. It doesn't have to be a bad thing, either. But you need to see that difference. And this is something John finds difficult to accept. He keeps describing ScriptBasic as this great, professional BASIC that is a real programming language (as oppose to the toy languages developed by other members here) and expects every single BASIC user and developer to share his enthusiasm and quit any other languages they happen to be using/developing. Well, it will never happen. I wish John didn't quit (I really struggle to find reason for it), but he's gone, so does it really matter what we're posting in this topic?

Title: Re: Notes on Script BASIC
Post by: Mike Lobanovsky on September 22, 2018, 10:27:36 PM
Smoke on the Water and Child in Time are unique phenomena in the hard rock culture and as such cannot be replicated or rivaled. ;D

Thanks for bringing me up to date with the cause of events in this thread. I must confess it was a little difficult for me to reconstruct it with some of John's responses evidently missing. Yet if I were in your shoes I'd most likely stop posting here and would rather open a couple of new threads to present the Python/Ruby examples as challenges for the BASIC-ers to compete. It's obvious there won't be a Script BASIC solution to them anyway though...
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 22, 2018, 11:01:45 PM
Smoke on the Water and Child in Time are unique phenomena in the hard rock culture and as such cannot be replicated or rivaled. ;D

Ritchie Blackmore in Child in Time - one of the greatest guitar solos in history (especially in the original version from In Rock). You see - it was still possible to achieve a higher level of off-topic.  ;D
Title: Re: Notes on Script BASIC
Post by: B+ on September 23, 2018, 03:25:28 AM
Uh! because Script ASIC doesn't structure variables the same as other PL's doesn't mean it couldn't produce same results in one elegant line, just needs some setup.

For example QB64 has next to nothing for array handling, I had to build a library just to sort an array of floats and some other tools for handling number arrays but I had all tools to make a function that does same as these built-ins of PL's you are showing off.

Code: [Select]
'Test Floats Array Tools Library.bas for QB64
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "descend", 0, 3) 'Tomaaz sample
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "ascend", -10, 5) 'test join tolerance
PRINT UniqueSortSlice$("120 135 345 345 1890 12 120 12 135 712 78 120", "descend", 3, 16)
PRINT UniqueSortSlice$("1 1.1 1.11 1.1 1.11 1. 1.0 1.111 .999999999999999999999999999999999999999", "ascend", 0, 1000) 'oh that's nice!!! but I think .99... is same as 1

FUNCTION UniqueSortSlice$ (NumberStr$, ascendDescend$, SliceStart AS LONG, SliceEnd AS LONG)
    REDIM temp(0) AS _FLOAT
    Split2Floats NumberStr$, " ", temp()
    uniqueFloats temp()
    qSortFloats LBOUND(temp), UBOUND(temp), temp()
    IF ascendDescend$ <> "ascend" THEN reverseFloats temp()
    UniqueSortSlice$ = JoinFloats$(temp(), SliceStart, SliceEnd, " ")
END FUNCTION

'$include: 'Floats Array Tools.bm'

See attached output. It would have been easier with Script Basic or with SmallBASIC because both use variant variable types and more advanced array stuff is already built into language.


How can the above possibly be construed as advocating QB64?

I thought I was defending the SB's for their variant type variables and advanced array manipulation over and above QB64 in that one department.

I thought I was demonstrating that even QB64 can do what Tomaaz was doing though it takes a few or many more lines.

So to be clear to everyone named Mike that is what I was attempting to do.

Here is the last line of the quote once again, in John's style:
See attached output. It would have been easier with Script Basic or with SmallBASIC because both use variant variable types and more advanced array stuff is already built into language.
Title: Re: Notes on Script BASIC
Post by: B+ on September 23, 2018, 03:46:06 AM
I built a special library to handle float arrays the same as you are showing, as strings$

I did build a special function because QB64 sucks as far as not being able to pass arrays through functions, not same problem with Script or SmallBASIC.

How hard is it to change your output to this? (attached)

And how do these things handle floats? The forth line? I am curious the decision it would make for 1, 1.0, 1. and .99.... would they be the same or each unique?

Tomaaz,

I am inquiring about how the language you are advocating handles a couple of things, did you miss it?

You didn't just setup a more difficult task to blow off my question did you?

And yes, I agree new tasks should go in a different board.

They really don't belong here, just the answer to my question. ;)

PS the library is not special for your task, it is a general set of useful tools for handling Float Arrays. Sure, they may come in handy in future dealings with Tomaaz Tasks. :)
Title: Re: Notes on Script BASIC
Post by: Peter on September 23, 2018, 08:02:21 AM
OK. Here is another task. Recursively walk directory, find all .jpg files which names are integers, sort the names by numbers and print the result.

I know why you proposed this task, and my code below is completely off-topic, but I simply couldn't resist solving this  :) I am interested to see how it looks in other BASIC variants.

Code: [Select]
SUB Recurse_Dir(STRING dir$)
    LOCAL here TYPE DIR*
    OPEN dir$ FOR DIRECTORY AS here
    WHILE TRUE
        GETFILE item$ FROM here
        IF NOT(LEN(item$)) THEN BREAK
        IF item$ = "." OR item$ = ".." THEN CONTINUE
        new$ = dir$ & "/" & item$
        IF FILETYPE(new$) = 2 THEN
            Recurse_Dir(new$)
        ELSE
            IF BASENAME$(new$, 2) = "jpg" AND REGEX(BASENAME$(new$, 1), "^[[:digit:]]*$") THEN result$ = APPEND$(result$, 0, new$, NL$)
        END IF
    WEND
    CLOSE DIRECTORY here
END SUB
Recurse_Dir(".")
PRINT SORT$(result$, NL$)

Yet if I were in your shoes I'd most likely stop posting here and would rather open a couple of new threads to present the Python/Ruby examples as challenges for the BASIC-ers to compete.

That is a great idea! It would stimulate improving implementations of BASIC.
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 23, 2018, 02:39:32 PM
Yes, that would be great, but I seriously doub " the WinApi guru" will let us do it. He's already declared Python, Perl, Ruby etc. to be "junk",  OOP to be " useles" and https to be "just another crap". When he sees my nickname together with the word " Python" in one post,  it's the end of serious discussion (this topic is a perfect example).
Title: Re: Notes on Script BASIC
Post by: B+ on September 23, 2018, 02:47:55 PM
Yes, that would be great, but I seriously doub " the WinApi guru" will let us do it. He's already declared Python, Perl, Ruby etc. to be "junk",  OOP to be " useles" and https to be "just another crap". When he sees my nickname together with the word " Python" in one post,  it's the end of serious discussion (this topic is a perfect example).

Yeah sure blame it on him. (Though it's definitely more than partly true, you love it.) I had a serious question, is it being ignored?

PS I am eager to try an SB out on this latest challenge, will someone please post something in another thread or do I have to do it again?
Title: Re: Notes on Script BASIC
Post by: Tomaaz on September 23, 2018, 04:02:37 PM
Yeah sure blame it on him. (Though it's definitely more than partly true, you love it.) I had a serious question, is it being ignored?

Sorry, but no - I don't like it. I prefer the kind of discussions you can have with zxDunny, Peter (BaCon) or Marcus (NaaLaa), for example. Remind me - were you a member of old basicprogramming forum? While it's fun to read Aurel's surreal English for some time, it becomes annoying very quickly and destroys every single topic, especially that 80% of his arguments are personal attacks, copy/paste insults and a demonstration of a total lack of knowledge of anything beyond BASIC and WinApi ("https is just another crap" etc.). But the worst are his lame attempts to be funny and make linguistic jokes.

Sorry, I missed you questions. Here are the answers:

How hard is it to change your output to this? (attached)

Python:
Code: [Select]
x = [120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120]
print(map(lambda a: "Tomaaz " + str(a), sorted(list(set(x)), reverse=True)[0:3]))

NewLisp:
Code: [Select]
(set 'x '(120 135 345 345 1890 12 120 12 135 712 78 120))
(println (map (fn (x) (append "Tomaaz " (string x))) (slice (sort(unique x) >) 0 3)))

And how do these things handle floats? The forth line? I am curious the decision it would make for 1, 1.0, 1. and .99.... would they be the same or each unique?

In Python and NewLisp 1 and 1.0 are treated as the same number. In Ruby they aren't. 0.99..... in all three languages is unique element, however, while Ruby and Python keep the value, NewLisp is changing it slightly to something like 0.99999989999 (different number representation).
Title: Re: Notes on Script BASIC
Post by: B+ on September 23, 2018, 04:21:20 PM
Thanks, Tomaaz, I did start your Dir Walk challenge in another thread with a couple of questions (I hope remarks to folks at ALL aren't too distracting.)

Why yes I was at BP.org, "moderating" uh himmm ... towards the end, you don't remember?

If I say stuff about you and Aurel, you know that invites him right back into conversation. It's really nutz when John invokes the   Aurel name just to see the show and he accuses me of playground stuff. Well it takes one to know one, I learned from a master. :P
Title: Re: Notes on Script BASIC
Post by: Aurel on September 23, 2018, 09:35:37 PM
Quote
and a demonstration of a total lack of knowledge of anything beyond BASIC

really --and what is that just another insult
If you learn few tricks you picked around that's don't make you great programmer.
so please continue with your "expertise" with your tiny brain examples
they are so charming  ;D ;D ;D