Author Topic: requests  (Read 15674 times)

SteveOW

  • Guest
requests
« on: June 30, 2013, 04:54:08 PM »
@Guilect

I wonder is there any chance of getting two extra functions in the next release of BB:- strokeEllipse, fillEllipse?

= = = = =

Also do you think it would be possible to have a "goto" command (and associated label statement)?
 
I assumed that javascript doesnt have such capability but after reading the following link the picture isnt clear.
http://stackoverflow.com/questions/9751207/how-can-i-use-goto-in-javascript.

cheers, SteveOW.

EDIT:
Just realized a simple way to implement goto:
Basic:  Goto LabelOne          JS:   If (1==2) {   //...Goto LabelOne
Basic:  LabelOne:                JS:   }                //...LabelOne:
leave it to the programmer to avoid jumping across control structures.
« Last Edit: July 15, 2013, 09:31:15 PM by Guilect »

Guilect

  • Guest
Re: requests goto and ellipse
« Reply #1 on: June 30, 2013, 11:08:20 PM »
Not a big fan of 'goto'.
But if it can be easily implemented I could do it and users could choose to use it or not.

I do not get your JS example.
Quote
If (1==2) {   //...Goto LabelOne
}                //...LabelOne:

I can make a keyword 'Goto' in BB what what is its JS equivelant that BB outputs?

The ellipse request seems doable.

{EDIT}:
I have implemented the stroke and fill ellipses.
When used each on their own they work fine.
But, like the POLY draw function, when used together the stroked one gets a extra outline.
I will continue to look into that.
« Last Edit: July 01, 2013, 12:11:40 AM by Guilect »

SteveOW

  • Guest
Re: requests goto and ellipse
« Reply #2 on: July 01, 2013, 10:04:41 AM »
@Guilect

Re: GOTO...Sorry my illustration was a bit confusing. :-[
Code: [Select]
Basic:  Goto abc123         
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  abc123:               

Here is the minimal JS required to implement the goto effect
JS:   If (1==2) { 
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:   }           

JS code with additional endline comments which explain to another programmer how a goto is being implemented
JS:   If (1==2) {     //  this line acts as a goto abc123
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:   }   // this line acts like a basic "label abc123"

I would not expect the compiler to auto-generate the end-line comments.
I dont expect the compiler to check the validity/safeness of the use to which goto is put.
Compiler must recognize that a basic statement "goto abc123" can be replaced simply by "if(1==2)"  It can ignore the specifics of the label.
Compiler must recognize that a statement like "abc123:" is a label (as in VB6) and simply replace it by a "}"

My main reason for having goto's is I find it helps in bug hunting to quickly and clearly jump over blocks of code that may harbour the bug.
In JS one can use the block comment start & end structure: /* .... ... ... */
But in VB6 (AFAIK) there is  no such start & end block comment facility.
Same seems to apply for BB. (I think I might include the facility in Browzic).

Second reason for using goto = it helps explain to Level 1 novices how computers really work, using near-natural language terms.
Then Level 2 novices can be allowed to confuse themselves with goto spaghetti.
Then Level 3 novices will appreciate the benefits of structured programming. :)

cheers, SteveOW.

PS I would be very glad to have fillEllipse, I can live with the outlining "feature".



Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: requests goto and ellipse
« Reply #3 on: July 01, 2013, 10:28:33 AM »
The only thing I can say is that I never ever needed GOTO the last 15 years. I only needed it on the Commodore64 but that BASIC had'nt advanced control structures.

SteveOW

  • Guest
Request for "Open Hyperlink"
« Reply #4 on: July 01, 2013, 10:34:19 AM »
@Guilect
Please could you provide an Open Hyperlink function in next release of BB?
Here is some JS which opens a hyperlink in a new browser tab when supplied with a url as a string:-

   var page_URL //as string
   page_URL = "sow_FRED.html"
   window.open(page_URL,'_newtab');

Cheers, SteveOW.

SteveOW

  • Guest
Re: requests goto and ellipse
« Reply #5 on: July 01, 2013, 11:48:59 AM »
@Cybermonkey

Sorry
I didnt mean to rattle anyone's cage by re-lighting the Goto Controversy
http://www.sonoma.edu/users/l/luvisi/goto/goto.pdf

I just found a solution published some time ago...
use "Come From" instead !!!
http://www.fortran.com/come_from.html ;)

cheers, SteveOW.

Guilect

  • Guest
Re: requests goto and ellipse
« Reply #6 on: July 01, 2013, 12:31:09 PM »
@SteveOW

How about this.
Two suggestions.

First,  use the method you just descibed.
If you want to programatically not have a section of code run
you can using BB syntax do:

If (1=2) then
    code you want to skip
    code you want to skip
    code you want to skip
    code you want to skip
endif

Or secondly, what I do if I want to skip code is to comment it out.
Even if it is a large block of code it is no problem with the editor that comes with BB
as it has a block comment feature under the edit menu.

SteveOW

  • Guest
Re: requests goto and ellipse
« Reply #7 on: July 01, 2013, 01:42:33 PM »
@Guilect,

Obviously I got no problem if you dont want to put GOTO & Labels into BB, its your baby.

Those two methods are obviously feasible workarounds.

[ramble]
Code: [Select]
For me Goto and Labels (as found in VB6) are useful and convenient.
Unlike those two methods my Goto & Labels stick out like sore thumbs in my code.
Which is exactly what I want them to do. 
They are like duct tape or temporary traffic signs.
They say "there is something unfinished here which needs attention at some time".
Whereas those two methods blend in with lots of my stable code.
I tend to use comments to de-activate fossil code which shows how the program used to do something.
I sometimes find it useful to keep such stuff hanging around for a few years.
Whereas my goto's & labels are often only in use for a few minutes until a bug has been cornered.
[/ramble]

cheers, SteveOW. :)

PS My PN.exe inserts !~ as comment instead of '.
maybe due to current scheme in PN being "Fortran 95" ?

Guilect

  • Guest
Re: requests goto and ellipse
« Reply #8 on: July 01, 2013, 03:08:41 PM »
Quote
PS My PN.exe inserts !~ as comment instead of '.
maybe due to current scheme in PN being "Fortran 95" ?

I will look into the comment character insertion.

The lexer needs to be set to Fortran 95.
This is the built in lexer in the scintilla control.
It turns out that the fortran language is the closest to BB's regarding functions, for loops, and if-then statements.
Selecting Fortran allows the editor to (mostly) process BB code correctly for code folding of functions, if-thens, for-next loops, etc.

SteveOW

  • Guest
Request for NO_CLEAR option
« Reply #9 on: July 15, 2013, 11:05:06 AM »
@Guilect
Am trying to port Tomaaz's javascript prog for Langtons Ant into BrowserBasic (see BB code below).
It works alright except that BB refreshes the screen on every repeat call to the OnDraw function.

I have tried writing the image to an array and repainting the image on every step of the loop.
But this makes the prog very slow (40 minutes instead of 1 minute to complete 12000 steps).

Would it be possible to provide an option in BB that prevents the clearing of the old canvas image?

Alternatively could there be a way for a BB programmer to manipulate an image in a buffer and then onevery step to rapidly "BitBlt" the image from the buffer to the screen/canvas?

cheers, SteveOW.

PS Maybe this Topic could be renamed "Requests"?

Code: [Select]
'... Global Vars

var PixelData[4] as array
var PixelDataLong as number
var steps as number
var x as number
var y as number
var Direction as number
var scaler as number

'... Initialisation
Function OnLoad()

scaler = 1
steps = 12000
x = 100*scaler
y = 100* scaler
Direction = 1

endfunction

'... Update

Function OnUpdate()
endfunction

'... Draw

Function OnDraw()

PixelDataLong = getPixel(x,y)

if PixelDataLong > 0 then '...black
setColor (0,0,0) '...white
setPixel(x,y)    '...paint pixel
''fillRect(x,y,1*scaler,1*scaler)

select Direction
case 1
Direction = 4
x=x+  scaler
break
case 2
Direction = 1
y=y+  scaler
break
case 3
Direction = 2
x=x-  scaler
break
case 4
Direction = 3
y=y-  scaler
break
endselect
else
setColor (255,255,255) '...black
setPixel(x,y)    '...paint pixel
''fillRect(x,y,1*scaler,1*scaler)

select Direction
case 1
Direction = 2
x=x-  scaler
break
case 2
Direction = 3
y=y-  scaler
break
case 3
Direction = 4
x=x+  scaler
break
case 4
Direction = 1
y=y+  scaler
break
endselect
endif
steps = steps-1

if steps= 0 then
msgbox("Finished")
endif

endfunction '...OnDraw()


Guilect

  • Guest
Re: requests
« Reply #10 on: July 15, 2013, 09:36:31 PM »
Hi SteveOW,

I can allow the user to create a hidden canvas, draw to it, and then flip it to the main canvas.

Something like this (pseudo code):

var mycanvas as number
mycanvas = CreateCanvas()

func. OnUpdate()
    SetCanvas(mycanvas)
' draw your stuff to your canvas

endfunc.
   
func. OnDraw()
    setCanvas(mycanvas)
endfunc.

SteveOW

  • Guest
Re: requests
« Reply #11 on: July 16, 2013, 12:00:12 AM »
@Guilect,
I can allow the user to create a hidden canvas, draw to it, and then flip it to the main canvas.
That sounds good.
But I dont understand your pseudo-code.
Maybe something like:-
Code: [Select]
Function Update()
   If UserChooses then ClearCanvas(MyCanvas)
   SetDrawCanvas(MyCanvas)
   draw stuff (to MyCanvas)
endFunction

Function Draw()
   CopyCanvas(MyCanvas, OutputCanvas)
   DisplayCanvas(OutputCanvas)
endFunction

SteveOW

  • Guest
New request: Append input BB source code to output HTML file
« Reply #12 on: August 24, 2013, 11:47:23 PM »
@Guilect,

I think it could be useful for the HTML file outputted by the BB compiler to include (as a commented-out appendix) the BB source code which was originally input.

That way someone interested in examining or forking the source code could simply extract it from the HTML file.
This would save the provider having to post parallel html and BB files.

Of course some authors would prefer not to share their code and so this would be provided as an option for the author to select prior to compiling.

What do you think?

SteveOW

  • Guest
Request: html <title> definition in BB
« Reply #13 on: August 25, 2013, 12:02:32 AM »
It would be nice for coder to have ability to specify the value of the html page title field from within a BB code statement
e.g. status = Define_Page_Title ("Peter's Page").
Thus the text appearing on the tab for a BB page could be short and simple rather than the default rambling filespec.

The required html code is simple:
<title>Peter's Page</title>

Guilect

  • Guest
Re: requests
« Reply #14 on: August 25, 2013, 04:41:39 PM »
@SteveOW

Being able to set the title page makes sense.
I will see about getting it into the next release.

I know you would like to have the BB source output in the .html file.
Not sure how many other users (does BB have any other users besides you?) would make use of that.  By including the BB source in the html you have just doubled the size and download time of the file.  Will look into it.