|
Post by tsh73 on Mar 27, 2021 15:37:19 GMT -5
I have a program (circular slide ruler) I just tried to rin in LB5 352 -32 Win10 And it does not work. And I know why, but I wonder if there should be / will be added a way around it.
You see, lb4 gets drawing commands from a string so I could create string function that returns drawing commands This program uses RotatedFont but I could do anything, say
function circ$(x,y,r) circ$="place ";x;" ";y;"; circle ";r end function
Then called it prints valid string
place 100 200; circle 30
I could store it in a string and then send to a graphicbox, and it works
c$=circ$(100,200,30) #gr c$
But if I try to put that function right into print to graphicbox statement,
#gr circ$(100,200,30)
it does not work, saying unrecognized command for #gr: CIRC$()
I understand that now #gr has functiions of it's own, among them #gr circle(r) but my function returns string so it could be easily distinguished from build-in ones.
Obviously it worked in old LB. Is there a way it could work in LB5?
' 'nomainwin open "test" for graphics as #gr #gr "trapclose [quit]" #gr "down" '#gr "fill white; flush" #gr "home; posxy cx cy"
#gr "home; circle 50"
print circ$(100,200,30) 'prints 'place 100 200; circle 30
c$=circ$(100,200,30) #gr c$ 'draws circle
''!! try to uncomment that '#gr circ$(100,200,30) 'does not work, says 'unrecognized command for #gr: CIRC$()
#gr "flush" wait
[quit] timer 0 close #gr end
function circ$(x,y,r) circ$="place ";x;" ";y;"; circle ";r end function
|
|
|
Post by Stefan Pendl on Mar 27, 2021 16:07:35 GMT -5
If you prepend an empty string the custom function is valid.
#gr ""; circ$(100,200,30) This could be a work around until custom functions returning strings are supported.
|
|
|
Post by Carl Gundel on Mar 27, 2021 18:15:13 GMT -5
If you prepend an empty string the custom function is valid. #gr ""; circ$(100,200,30) This could be a work around until custom functions returning strings are supported. Or you might do it this way. open "draw a circle" for graphics as #draw
print #draw, circ$(50, 50, 30)
wait
function circ$(x, y, r)
circ$ = "place "; x; " "; y; "; circle "; r
end function In Liberty BASIC v4.5.1 you can do it this way: #draw, circ$(x, y, r) But this doesn't work in LB5, so I think this should be considered a bug in LB5. Thanks for this very useful feedback. -Carl
|
|