Author Topic: Why do you care that much about BASIC part in the name of a language?  (Read 33267 times)

Richly

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #90 on: August 29, 2016, 12:01:54 AM »
I'm enjoying learning C, but sometimes BASIC is so much simpler. It struck me again when I was completing an exercise to display the powers of 2.

Here is the C version...

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

int main()
{
    int b=0;
    float value=2.0;
    int increment=0;
    float result;

    for(b=0;b<=10;b++)
    {
       result=pow(value,increment);
       printf("%.1f to the power of %d is %.1f\n",value,increment,result);
       increment+=1.0;
    }
    return 0;
}

Here is the alternative in BASIC using SpecBAS...

Code: [Select]
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP

jj2007

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #91 on: August 29, 2016, 12:03:59 AM »
CASE can't take an expression - it can in Pascal, and also in SpecBAS

And a few others  :)

Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals int somevar=5
Init
  m2m ecx, -5
  PrintLine "----------------------------- testing the new MasmBasic Switch_ macro -----------------------------"
  .Repeat
Print Str$(ecx), Tb$
m2m edx, -127 ; don't trigger the edx case...
If_ ecx==11 Then mov edx, ecx ; ... except for testing the Case_ edx at position 11
Switch_ ecx
Case_ somevar
PrintLine Str$("Case var=%i", somevar)
Case_ edx ; this case triggered if ecx==edx; takes preference over 'immediate'
PrintLine "Case edx ###" ; cases but must come before lt or gt cases
Case_ lt -2
PrintLine "Case less than -2"
Case_ -2
PrintLine "Case -2"
Case_ 0
PrintLine "Case NULL"
Case_ 10, 12
PrintLine "Case 10 or 12"
Case_ 18
PrintLine "Case 18"
Case_ 14 .. 16 : PrintLine "Case 14 .. 16 (one-liner)" ; OK if only one instruction is needed
Default_
PrintLine "---" ; no matching case found
Endsw_
inc ecx
  .Until signed ecx>20
  Inkey "You better switch to MasmBasic"
EndOfCode

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #92 on: August 29, 2016, 01:02:11 AM »
JJ,

Just to put things in the proper perspective, does anyone use masmbasic for anything useful other than you?

jj2007

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #93 on: August 29, 2016, 01:29:54 AM »
Hey, don't tell me that you are the Spikowski troll who sent out his lawyers and wanted to shut down the other forum. Really, still around? What do your shrinks tell you nowadays?

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #94 on: August 29, 2016, 02:26:56 AM »
Thanks for answering my question in your classic bitter way.

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #95 on: August 29, 2016, 08:01:36 AM »
I'm enjoying learning C, but sometimes BASIC is so much simpler. It struck me again when I was completing an exercise to display the powers of 2.

Here is the C version...

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

int main()
{
    int b=0;
    float value=2.0;
    int increment=0;
    float result;

    for(b=0;b<=10;b++)
    {
       result=pow(value,increment);
       printf("%.1f to the power of %d is %.1f\n",value,increment,result);
       increment+=1.0;
    }
    return 0;
}

Here is the alternative in BASIC using SpecBAS...

Code: [Select]
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP

Here is the C BASIC version of it.

Code: [Select]
#include <stdio.h>
#include <math.h>
#include "cbasic.h"

MAIN
BEGIN_FUNCTION
  DIM AS int b = 0;
  DIM AS int increment = 0;
  DIM AS float value = 2.0;
  DIM AS float result;
 
  DEF_FOR (b = 0 TO b <= 10 STEP INCR b)
  BEGIN_FOR
    result = POW(value, increment);
    PRINT ("%.1f to the power of %d is %.1f\n", value, increment, result);
    increment += 1.0;
  NEXT
  RETURN_FUNCTION (0);
END_FUNCTION 


jrs@laptop:~/c_basic$ gcc cpow.c -lm -o cpow
jrs@laptop:~/c_basic$ ./cpow
2.0 to the power of 0 is 1.0
2.0 to the power of 1 is 2.0
2.0 to the power of 2 is 4.0
2.0 to the power of 3 is 8.0
2.0 to the power of 4 is 16.0
2.0 to the power of 5 is 32.0
2.0 to the power of 6 is 64.0
2.0 to the power of 7 is 128.0
2.0 to the power of 8 is 256.0
2.0 to the power of 9 is 512.0
2.0 to the power of 10 is 1024.0
jrs@laptop:~/c_basic$

« Last Edit: August 29, 2016, 08:04:11 AM by John »

Richly

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #96 on: August 29, 2016, 10:58:22 AM »
Thanks John. Interesting to see the two languages combined like this.

jj2007

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #97 on: August 29, 2016, 12:53:05 PM »
Thanks for answering my question in your classic bitter way.

John Spikowski,

Your "question" was a personal attack, everybody can see that:
Just to put things in the proper perspective, does anyone use masmbasic for anything useful other than you?

And don't believe that anybody who was on BP.org at the time will ever forget that you threatened through your lawyers to shut down the site, thus destroying years of work of the forum members. The Internet has a damn good memory, Spikowski.

ZXDunny

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #98 on: August 29, 2016, 02:15:06 PM »
I can count the number of active users of SpecBAS on one hand. Why is that a problem?

B+

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #99 on: August 29, 2016, 04:26:49 PM »
Hi Richey,

Since we are off topic in the off topic place, here is SmallBASIC version of your code:
Code: [Select]
for power in seq(0, 10, 11) do ? 2 ^ power;" ";

jj2007

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #100 on: August 29, 2016, 04:49:36 PM »
No way to do it in one line, but here at least we see the use of Genuine BasicTM line numbers:

Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc
Init
  mov ebx, 1
_10:
  Print Str$("%i ", ebx)
  shl ebx, 1
  cmp ebx, 1024
  jbe _10
  Inkey Chr$(13, 10, "This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
EndOfCode

Output:
Code: [Select]
1 2 4 8 16 32 64 128 256 512 1024
This code was assembled with JWasm in 64-bit format

 ;)

B+

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #101 on: August 29, 2016, 04:51:02 PM »
Here is another highly evolved BASIC dialect (JB v1.01) that does boolean evaluations in Select Case:
Code: [Select]
goPlace = 1
while goPlace <> 0
    print : input "Enter number for place to go to "; go$
    goPlace = val(go$)
    select case
    case goPlace < 0
        print "Going down!"
    case goPlace > 0
        print "Going up!"
    case len(go$) > 0 and goPlace = 0 and go$ <> "0"
        print "Did you enter a number?"
        goPlace = 1
    case goPlace = 0
        print "Going no where!"
    end select
wend


Output
Quote
Enter number for place to go to Montana
Did you enter a number?

Enter number for place to go to -100
Going down!

Enter number for place to go to 100
Going up!

Enter number for place to go to -9999999999999999999999999999999999999.9999999999999999999999999999999999999999999
Going down!

Enter number for place to go to 0
Going no where!


« Last Edit: August 29, 2016, 05:23:57 PM by B+ »

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #102 on: August 29, 2016, 04:57:24 PM »
Thanks John. Interesting to see the two languages combined like this.

I have been using C BASIC for all my Script BASIC extension modules. More or less for clarity and self documenting.
« Last Edit: August 29, 2016, 05:35:00 PM by John »

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #103 on: August 29, 2016, 06:00:43 PM »
Quote
Genuine BasicTM

BASIC masturbation.  :)

ZXDunny

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #104 on: August 29, 2016, 08:35:20 PM »
Hi Richey,

Since we are off topic in the off topic place, here is SmallBASIC version of your code:
Code: [Select]
for power in seq(0, 10, 11) do ? 2 ^ power;" ";

And in SpecBAS:

Code: [Select]
10 FOR EACH i IN [0 TO 10]: PRINT 2^i;" ";: NEXT i

Very similar.

JJ: What happens if we GO TO 11 (jbe _11) in your last snippet? :)