Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Ken Perlins strange code

  1. #11
    Your example looks more like the ScriptBasic Version. It's interesting how the same code generates different results.

    I would like to see a thinBasic version if anyone is willing to give it a try.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  2. #12
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    this is cool, would like to see in oxygen

    In looking at Mathews page and code, I really liked how variables were declared.
    dim x, y, k, i#, j#, r#, b$

    This would be neat to have this simplification in Oxygen... now there are too many types. I know the types are needed in the background for Oxygen to use C code, but it would be neat if the main oxygen user who just write in Oxygen had such a simple way of only 3 choices and maybe one more of bool.

    In the above code it is obvious what are whole numbers, decimal and string. For bool perhaps a ? could be used.

  3. #13
    Well we get fairly close. Oxygen will support these:

    dim as long a,b,c,double d, string s,t="q"
    
    dim long a,b,c, double d, string s,t="q"
    
    long a,b,c, double d, string s,t="q"
    
    dim x,y,z 'these default to sys type (long)
    
    For casual programming it is not necessary to dim the variables, as long as the type can in inferred by the first assignment.

    s="this is a dynamic string"
    d=42.5 'double
    a=32 'sys / long
    
    Charles
    Last edited by Charles Pegge; 16-06-2011 at 10:16.

  4. #14
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405
    Thanks for the clarification Charles, for instance didn't know about:
    dim x,y,z 'these default to sys type (long)

    I keep forgetting we are in alpha versions of oxygen.
    It just seems so much further along and that it is time for a users manual

  5. #15
    I keep on discovering new semantics . Fortunately the keyword list stopped growing some time ago and the manual covers these at least.

    Charles

  6. #16
    My worst effort so far:

    
    /*
    Ken Perlin's Original
    C
    main(k){float i,j,r,x,y=-16;while(puts(""),y++<15)for(x
    =0;x++<84;putchar(" .:-;!/>)|&IH%*#"[k&15]))for(i=k=r=0;
    j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111;r=j);}
    */
    
    'OxygenBasic
    single x,y,k,i,j,r:string b:for y=-16 to 16:for x=1 to 84
    b+=mid" .:-;!/>)|&IH%*#",1+(k & 15),1:i=0:k=0:r=0:while 1
    {j=r*r-i*i-2+x*.04:i=2*r*i+y*.1:r=j:if k++>110|i*i+j*j>11
    {exit do}}next:b+=chr(13)chr(10):next:putfile"m.txt",b
    
    Charles

  7. #17
    Charles,

    I thought I would try your newest version under SB. All it printed was a # for the first position of the first line. I thought at first that SB must not support a FOR/NEXT with a negative value. (wrong)

    'OxygenBasic
    single x,y,k,i,j,r:string b:for y=-16 to 16:for x=1 to 84
    b+=mid" .:-;!/>)|&IH%*#",1+(k & 15),1:i=0:k=0:r=0:while 1
    {j=r*r-i*i-2+x*.04:i=2*r*i+y*.1:r=j:if k++>110|i*i+j*j>11
    {exit do}}next:b+=chr(13)chr(10):next:putfile"m.txt",b
    
    
     ::::::::::::::::::--------------------------------------::::::::::::::::::::::::::: 
    ::::::::::::::------------------------------------------------:::::::::::::::::::::: 
    ::::::::::--------------------------------------------------------:::::::::::::::::: 
    ::::::----------------------------------;;;;;;;;;;;-------------------:::::::::::::: 
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------:::::::::::: 
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------::::::::: 
    :------------------------;;;;;;;;;;;;;!!!!//>)I#&H /!!!;;;;;;;;--------------::::::: 
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&:# &)>//!!!!;;;;;;;--------------::::: 
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-    /-&>>///!!!!;;;;;--------------:::: 
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H      %I||)>>>>#/!!;;;;;-------------::: 
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-   &             .H%I#H >!!;;;;;-------------:: 
    :-----;;;;;;;;;!!!!///////////>>)&:%-                      H)>/!!;;;;;-------------: 
    :-;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.                        *&I>/!!;;;;-------------- 
    :;;;;;;;;!!!!!//>>|I..!H#;% I&&I>                           #|>/!!;;;;;------------- 
    -;;;;;!!!!!///>>)|H%-;                                       I//!!;;;;;------------- 
    -!!!!/////>>>)|%*:##           #                            |>/!!!;;;;;;------------ 
    -                                                        .I|>//!!!;;;;;;------------ 
    -!!!!/////>>>)|%*:##           #                            |>/!!!;;;;;;------------ 
    -;;;;;!!!!!///>>)|H%-;                                       I//!!;;;;;------------- 
    -;;;;;;;;!!!!!//>>|I..!H#;% I&&I>                           #|>/!!;;;;;------------- 
    --;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.                        *&I>/!!;;;;-------------- 
    :-----;;;;;;;;;!!!!///////////>>)&:%-                      H)>/!!;;;;;-------------: 
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-   &             .H%I#H >!!;;;;;-------------:: 
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H      %I||)>>>>#/!!;;;;;-------------::: 
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-    /-&>>///!!!!;;;;;--------------:::: 
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&:# &)>//!!!!;;;;;;;--------------::::: 
    :------------------------;;;;;;;;;;;;;!!!!//>)I#&H /!!!;;;;;;;;--------------::::::: 
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------::::::::: 
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------:::::::::::: 
    ::::::----------------------------------;;;;;;;;;;;-------------------:::::::::::::: 
    ::::::::::--------------------------------------------------------:::::::::::::::::: 
    ::::::::::::::------------------------------------------------:::::::::::::::::::::: 
    :::::::::::::::::::--------------------------------------:::::::::::::::::::::::::::
    
    'ScriptBasic
    for y=-16 to 16
      for x=1 to 84
        b&=mid(" .:-;!/>)|&IH%*#",1+(k & 15),1)
        i=0
        k=0
        r=0
        repeat
          j=r*r-i*i-2+x*.04
          i=2*r*i+y*.1
          r=j
          k+=1 
        until k>110 or i*i+j*j>11
      next
      b&="\n"
    next
    print b
    
    Here is my test of FOR/NEXT in SB.

    for x=-5 to 5
      print x,"\n"
    next
    
    jrs@laptop:~/sb/test$ scriba testfor.sb
    -5
    -4
    -3
    -2
    -1
    0
    1
    2
    3
    4
    5
    jrs@laptop:~/sb/test$
    
    My error. I forgot to change your & to and.

    'ScriptBasic
    for y=-16 to 16
      for x=1 to 84
        b&=mid(" .:-;!/>)|&IH%*#",1+(k and 15),1)
        i=0
        k=0
        r=0
        repeat
          j=r*r-i*i-2+x*.04
          i=2*r*i+y*.1
          r=j
          k+=1 
        until k>110 or i*i+j*j>11
      next y
      b&="\n"
    next 
    print b
    
     ::::::::::::::::::--------------------------------------:::::::::::::::::::::::::::
    ::::::::::::::------------------------------------------------::::::::::::::::::::::
    ::::::::::--------------------------------------------------------::::::::::::::::::
    ::::::----------------------------------;;;;;;;;;;;-------------------::::::::::::::
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------::::::::::::
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------:::::::::
    :------------------------;;;;;;;;;;;;;!!!!//>)I#&HH/!!!;;;;;;;;--------------:::::::
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&:# &)>//!!!!;;;;;;;--------------:::::
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-####/-&>>///!!!!;;;;;--------------::::
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H #####%I||)>>>>#/!!;;;;;-------------:::
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-## &#############.H%I#H >!!;;;;;-------------::
    :-----;;;;;;;;;!!!!///////////>>)&:%-##################### H)>/!!;;;;;-------------:
    :-;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.########################*&I>/!!;;;;--------------
    :;;;;;;;;!!!!!//>>|I.-!H#;% I&&I>############################|>/!!;;;;;-------------
    -;;;;;!!!!!///>>)|H%-;########  ############################ I//!!;;;;;-------------
    -!!!!/////>>>)|%*:##########################################|>/!!!;;;;;;------------
    -########################################################.I|>//!!!;;;;;;------------
    -!!!!/////>>>)|%*:##########################################|>/!!!;;;;;;------------
    -;;;;;!!!!!///>>)|H%-;########  ############################ I//!!;;;;;-------------
    -;;;;;;;;!!!!!//>>|I.-!H#;% I&&I>############################|>/!!;;;;;-------------
    --;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.########################*&I>/!!;;;;--------------
    :-----;;;;;;;;;!!!!///////////>>)&:%-##################### H)>/!!;;;;;-------------:
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-## &#############.H%I#H >!!;;;;;-------------::
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H #####%I||)>>>>#/!!;;;;;-------------:::
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-####/-&>>///!!!!;;;;;--------------::::
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&:# &)>//!!!!;;;;;;;--------------:::::
    :------------------------;;;;;;;;;;;;;!!!!//>)I#&HH/!!!;;;;;;;;--------------:::::::
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------:::::::::
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------::::::::::::
    ::::::----------------------------------;;;;;;;;;;;-------------------::::::::::::::
    ::::::::::--------------------------------------------------------::::::::::::::::::
    ::::::::::::::------------------------------------------------::::::::::::::::::::::
    :::::::::::::::::::--------------------------------------:::::::::::::::::::::::::::
    
    For grins, I swapped the first and last character of the mid() string and now it looks closer to yours and the original.

    'ScriptBasic
    for y=-16 to 16
      for x=1 to 84
        b&=mid("#.:-;!/>)|&IH%* ",1+(k and 15),1)
        i=0
        k=0
        r=0
        repeat
          j=r*r-i*i-2+x*.04
          i=2*r*i+y*.1
          r=j
          k+=1 
        until k>110 or i*i+j*j>11
      next y
      b&="\n"
    next 
    print b
    
    #::::::::::::::::::--------------------------------------:::::::::::::::::::::::::::
    ::::::::::::::------------------------------------------------::::::::::::::::::::::
    ::::::::::--------------------------------------------------------::::::::::::::::::
    ::::::----------------------------------;;;;;;;;;;;-------------------::::::::::::::
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------::::::::::::
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------:::::::::
    :------------------------;;;;;;;;;;;;;!!!!//>)I &HH/!!!;;;;;;;;--------------:::::::
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&: #&)>//!!!!;;;;;;;--------------:::::
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-    /-&>>///!!!!;;;;;--------------::::
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H#     %I||)>>>> /!!;;;;;-------------:::
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-  #&             .H%I H#>!!;;;;;-------------::
    :-----;;;;;;;;;!!!!///////////>>)&:%-                     #H)>/!!;;;;;-------------:
    :-;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.                        *&I>/!!;;;;--------------
    :;;;;;;;;!!!!!//>>|I.-!H ;%#I&&I>                            |>/!!;;;;;-------------
    -;;;;;!!!!!///>>)|H%-;        ##                            #I//!!;;;;;-------------
    -!!!!/////>>>)|%*:                                          |>/!!!;;;;;;------------
    -                                                        .I|>//!!!;;;;;;------------
    -!!!!/////>>>)|%*:                                          |>/!!!;;;;;;------------
    -;;;;;!!!!!///>>)|H%-;        ##                            #I//!!;;;;;-------------
    -;;;;;;;;!!!!!//>>|I.-!H ;%#I&&I>                            |>/!!;;;;;-------------
    --;;;;;;;;;;!!!!/>&&)>>))))>>))|&*.                        *&I>/!!;;;;--------------
    :-----;;;;;;;;;!!!!///////////>>)&:%-                     #H)>/!!;;;;;-------------:
    :--------;;;;;;;;;;!!!!!!!!!!///>>|%-  #&             .H%I H#>!!;;;;;-------------::
    :------------;;;;;;;;;;;;!!!!!!!//>)|H))|&&H#     %I||)>>>> /!!;;;;;-------------:::
    :----------------;;;;;;;;;;;;;!!!!!!////>>)&-    /-&>>///!!!!;;;;;--------------::::
    :--------------------;;;;;;;;;;;;;!!!!!!//>)|&: #&)>//!!!!;;;;;;;--------------:::::
    :------------------------;;;;;;;;;;;;;!!!!//>)I &HH/!!!;;;;;;;;--------------:::::::
    :---------------------------;;;;;;;;;;;;;!!!/-%//!!!;;;;;;;;---------------:::::::::
    ::::-----------------------------;;;;;;;;;;;;;;;;;;;;;;;;---------------::::::::::::
    ::::::----------------------------------;;;;;;;;;;;-------------------::::::::::::::
    ::::::::::--------------------------------------------------------::::::::::::::::::
    ::::::::::::::------------------------------------------------::::::::::::::::::::::
    :::::::::::::::::::--------------------------------------:::::::::::::::::::::::::::
    
    Last edited by John Spikowski; 17-06-2011 at 05:59.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

Page 2 of 2 FirstFirst 12

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •