Menu

[r376]: / XTEST.MPL  Maximize  Restore  History

Download this file

243 lines (196 with data), 4.1 kB

/*
  MPL - Micro Programming Language
  DEMO OF MPL PROGRAMING USED FOR TESTING
*/

##LIBHDR

.buff     = %128
.name     = "MPL STRINGS. This is kinda cool"
.info     = "this is a quick test. Still some bugs"
.please   = "Please enter some text: "
.youtyped = "You typed: "
.table    = 5,10,20,30,40,50
.names    = "Derek","was","here",0

apple     = 1
orange    = 52

next() apple+=1

main2() [
  apple=1; @[
    puti(apple);
    next();
    apple<>20
  ];
  apple=10; apple>0 @[
    puti(apple);
    apple-=1
  ];
  puti(imax(10,20));
  puti(imin(10,20))
]

inc(v) [
  !v=!v+1
]

fff() 45

test() fff

main22() [
  newline();
  puts(sdel(scpy(.buff, "DEREK! EVANS"),2,4));
  smid(.buff, "APPLE PEAR", 7,4);
  sins(.buff, "-WELCOME-", 2);
  sadd(.buff, "<<<");
  sins(.buff, ">>>", 1);
  puts(.buff);
  gets(.buff)
]

ttt(a!1,b) [
  a$!1=123;
  puti(a$!1);
  puti(b)
]

here(a,b%2,c) [
  a=10;
  c=20;
  b$%4 = 123;
  puti(c)
]

memtest(a,b,c,d,e,f) [
  writef("MEMUSED=%n*n", VUSE());
  puti(a=getvec(10));
  puti(b=getvec(20));
  puti(c=getvec(30));
  puti(d=getvec(40));
  puti(e=getvec(50));
  puti(f=getvec(60));
  writef("MEMUSED=%n*n", VUSE());
  freevec(f);
  freevec(e);
  freevec(d);
  freevec(c);
  freevec(b);
  freevec(a);
  Writef("MEMUSED=%n*n", VUSE());
  puti(a=getvec(10));
  puti(b=getvec(10));
  puti(c=getvec(10));
  puti(d=getvec(10));
  puti(e=getvec(10));
  puti(f=getvec(10));
  writef("MEMUSED=%n*n", VUSE());
  freevec(f);
  freevec(e);
  freevec(d);
  freevec(c);
  freevec(b);
  freevec(a);
  writef("MEMUSED=%n*n", VUSE());
  0
]

.derek:-1234

cold(a,b!10) [
  b$!0=1234;
  a=4567;
  puti(23);
  puti(!(a$));
  puti(b$!0)
]

hello.there() puts("HELLO THERE")
hello.there() puts("HELLO THERE (REDEFINED)")

get.counter=0 [
  counter=1
::get.counter() [
    fputs("counter:", stdout);
    counter++
  ]
]

// main entry point, just like c/c++

.(s,i,fp) [
  i=10;
  !i++; puti(i);
  %i++; puti(i);
  WRITET("HELLO", 6);WRITES("THERE");NEWLINE();
  puti(get.counter());
  puti(get.counter());
  hello.there();

//cold();
  puti(.derek);
  s=101;
  writen(s&=1);
  writen(s);
  reads(.buff);
  memtest();
  apple=10;
    puti(apple--);
    puti(apple);
  scpy(.buff, "AEREK");
  apple = .buff;
  puti(apple);
  puti(%apple++);
  puti(apple);
//puti(!(.table+2)-=1);
//puti(!(.table+2));
  puti(compstring("DEREK", "AEREK"));
  reads(.buff);
  puts(.buff);
  CLRSCR();
  newline();

  puti(str2numb("-4321"));

  newline();

  writet("A",2);
  writet("A",2);
  writebin(16,8);

  newline();
  writef("%s here %s %oa*n", "DEREK IS", "NOW", 10);
  WriteS("APPLE*n");
  wrch(toupper('z'));
  gets(.buff);

  ttt(10,20,30);

  main22();
  puti(imax(10,20));

  i=0;i<=10 @ [puti(i);i+=1];

  puti(-test()());

  puti(SFIX(.buff,1000));

  writes("writing file ...*n");
  (fp=fopen("test.txt","w")) ? [
    writen(fp);
    writes("HERE*n");
    fprintf(fp,"Welcome to MPL.. %i*n", 2018);
    fprintf(fp,"Welcome to MPL.. %i*n", 2019);
    fprintf(fp,"Welcome to MPL.. %i*n", 2020);
    i=1;i<=10 @ fprintf(fp,"Numbers #%i*n", i++);
    fclose(fp)
  ];

  puti(-1234);
  puti(-1234);

  writef("hello [number=%n]%% %s there %s*n*n", -123, "derek", "again");

  puts(sadd(scpy(.buff, "DEREK"), " EVANS."));

  puti(apple);
  puti(imin(10,20));
  printf("Welcome to MPL. %s %d*n*n", "THIS IS DAM COOL!", 2018*2);
  cputs(.please);
  gets(.buff);
  cputs(.youtyped);
  puts(.buff);

  s=puts;
  s("Hello THERE FROM MPL-------------");

  .table!2=s;
  .table!2("This is called via a vector table");

  .table!2=123;

  i=!.table; i @ [
    puti(.table!i);
    i-=1
  ];

  i=.names; %i @ [
    puts(i); 
    i+=%i+1
  ];

  puts("INC TEST");
  i=123;
  puti(inc(i$));

  apple=10;

  puti(inc(apple$));
  puti(inc(apple$));
  puti(inc(apple$));
  puti(inc(apple$));

  apple=1;
  apple=-apple*10+2
]

// end of program


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.