mibuso.com

Microsoft Business Solutions online community
It is currently Tue Sep 16, 2014 2:51 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: NAV Brainfuck
PostPosted: Wed Jun 18, 2008 1:31 pm 
Offline

Joined: Wed May 10, 2006 11:25 am
Posts: 149
Location: Kiev
Country: Ukraine (ua)
Hi All

HYPERLINK(Execute('++++[>+++.... where am I? :roll:


Code: Select all
OBJECT Codeunit 60000 Brainfuck Interpreter
{
  OBJECT-PROPERTIES
  {
    Date=18-06-08;
    Time=[ 2:23:56 ];
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            CASE STRMENU('1. hello,2. i/o,3. reverse,4. mibuso,5. my birthday') OF
              1: MESSAGE(Execute(Text001));
              2: MESSAGE(Execute(Text002));
              3: MESSAGE(Execute(Text003));
              4: HYPERLINK(Execute(Text004));
              5: MESSAGE(Execute(Text005));
            END;
          END;

  }
  CODE
  {
    VAR
      Text001@1150000 : TextConst 'ENU=++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.';
      Text002@1150001 : TextConst 'ENU=,[.>]';
      Text003@1150002 : TextConst 'ENU=,[.>]<[.<]';
      Text004@1150003 : TextConst 'ENU=+++++++++++[>++++++++++<-]>-.----.-------.<++[>++++++++++<-]>-.--.----.>+++++++++[>+++++<-]>+.<<------------.++++++++++++.--.';
      Text005@1150004 : TextConst 'ENU=+++++[>+++++++++>+++++++++<<-]>++>+++++.-.<.>-.++++++.<.>+..';

    PROCEDURE Execute@1150000(strCode@1150000 : Text[1024]) strResult : Text[1024];
    VAR
      ip@1150001 : Integer;
      mem@1150002 : ARRAY [1024] OF Integer;
      d@1150004 : Dialog;
      i@1150005 : Integer;
      s@1150006 : Text[250];
      c@1150007 : Char;
      offset@1150003 : Integer;
    BEGIN
      // clear ..
      ip := 1;
      offset := 1;
      CLEAR(mem);

      // interpretation ..
      WHILE ip <= STRLEN(strCode) DO BEGIN
        CASE strCode[ip] OF
          '>': offset := offset + 1;
          '<': offset := offset - 1;
          '+': mem[offset] := mem[offset] + 1;
          '-': mem[offset] := mem[offset] - 1;
          '.': BEGIN
                 c := mem[offset];
                 strResult := strResult + FORMAT(c);
               END;
          ',': BEGIN
                 CLEAR(s);
                 d.OPEN('Input#1##############');
                 d.INPUT(1,s);
                 d.CLOSE;
                 FOR i := 1 TO STRLEN(s) DO
                   mem[offset+i-1] := s[i];
               END;
          '[': BEGIN
                 IF offset IN [1..1024] THEN
                   IF mem[offset] = 0 THEN
                     WHILE (strCode[ip] <> ']') AND (ip IN [1..1023]) DO
                       ip := ip + 1;
               END;
          ']': BEGIN
                 IF (offset >= 1) AND (offset <= 1024) THEN
                   IF  mem[offset] <> 0 THEN
                     WHILE (strCode[ip] <> '[') AND (ip IN [2..1024]) DO
                       ip := ip - 1;
               END;
        END;
        ip := ip + 1;
      END;
    END;

    BEGIN
    END.
  }
}

_________________
Yaroslav Gaponov


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 2:32 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12440
Location: Brno
Country: Czech Republic (cz)
it is something like Turing Machine... ;-)

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 3:15 pm 
Offline

Joined: Wed May 10, 2006 11:25 am
Posts: 149
Location: Kiev
Country: Ukraine (ua)
kine wrote:
it is something like Turing Machine... ;-)


Yes, Turing-complete language
http://en.wikipedia.org/wiki/Brainfuck

_________________
Yaroslav Gaponov


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 3:17 pm 
Offline

Joined: Tue Aug 17, 2004 4:06 pm
Posts: 866
Location: Heeswijk
Country: Netherlands (nl)
:-k
:roll:
=D>

_________________
----------------------------------
Tino Ruijs
Microsoft Dynamics NAV (Navision) specialist


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 6:23 pm 
Offline

Joined: Wed Jan 17, 2007 4:54 pm
Posts: 108
Location: Etten leur
Country: Netherlands (nl)
RESPECT :!:

_________________
**********************
** SI ** Bert Van Gestel **
**********************


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: