Liberty BASIC Community Forum
« IDE with draw tools Special note »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 6:06pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: IDE with draw tools Special note  (Read 1072 times)
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx IDE with draw tools Special note
« Thread started on: Jan 18th, 2016, 01:35am »

NOTE: Make sure you are in main directory with BMP folder.
Enable first line of code when you are sure you are in the right directory ***

*<ENTER> runs stored code and refreshes screen

* The ADD button adds a line or circle or rectangle you make

* LEFT / RIGHT mouse buttons for draws

*Make sure you have it on an empty line when you ADD
Code:
'Sept 2016 
'on error goto [Error]
  dim info$(10,10)
  DIM li$(100)'
 global adnote
 global lstat
 global cstat
 global bstat
 global constx'
 global consty
 global consth
 global constv
 global errstate$
 global lin
 global ideloc
 global r
 global g
 global b
 bmpbutton #h.red, "bmp\redbttn.bmp",redclicked, UR,10,10
 bmpbutton #h.blue, "bmp\bluebttn.bmp",blueclicked , UR, 10,130
 bmpbutton #h.green, "bmp\grnbttn.bmp",greenclicked, UR, 10,70
 bmpbutton #h.mred, "bmp\blank5.bmp",mredclicked, UR, 10,40
 bmpbutton #h.mblue, "bmp\blank4.bmp",mblueclicked, UR, 10,160
 bmpbutton #h.mgreen, "bmp\blank3.bmp",mgreenclicked, UR, 10,100
 bmpbutton #h.all, "bmp\grphbttn.bmp",allclicked, UR, 100,160
 bmpbutton #h.minusall, "bmp\sqrbttn.bmp",minusallclicked, UR, 130, 160
 bmpbutton #h.load,"bmp\OPEN.bmp",[loadit],UR 10,200
 bmpbutton #h.save,"bmp\SAVE.bmp",[saveit],UR 10,230
 bmpbutton #h.compile,"bmp\xxRun.bmp",[compileit],UR 10,260
 bmpbutton #h.helpmsg,"bmp\help.bmp",[HELPME],LL 950,50
 bmpbutton #h.lined,"bmp\LINEBTTN.bmp",[linedra],LL 950,100
 bmpbutton #h.circd,"bmp\CIRCBTTN.bmp",[circledra],LL 980,100
 bmpbutton #h.sqared,"bmp\SQRBTTN.bmp",[squaredraw],LL 1010,100
 bmpbutton #h.add,"bmp\ADDBTTN.bmp",[addit],LL 980,140
 lin =0
 r=50
 g=50
 b=50
call screen 1200,600
#h.4 "cls;place 10 30;down;backcolor 120 130 125;color white;fill 120 130 125"
#h.4 "\ Click on the ? to get helpful hints-"
errstate$="no"
gcolor$="white"
#h.2, "down;place 10 40;color blue;\";li$(lin);"_"
#h.3 "down;color 140 75 145;backcolor black;place 10 330"
#h.3 "\Hold Left or Right Mouse Button"
#h.3 "place 10 350;\to get a location (needs movement)"
#h.3 "color green;place 150 215;\LOAD"
#h.3 "place 150 245;\SAVE"
#h.3 "place 145 275;\COMPILE"
scan
#h.1 "when leftButtonMove [mouseloc]"
#h.1 "when rightButtonMove [rmouseloc]"
   #h.2 "setfocus;place 10 20"
   #h.2 "when characterInput [inp]"
[back]
if adnote=1 then adnote=0: call runit
   wait
[quit]'
 timer 0
  #h.1 "discard"
 close #h
 end
 [addit]
 txt$=currdraw$
 adnote=1
 goto [inp]
 [linedra]
 if lstat=0 then lstat=1 else lstat=0
 if lstat=1 then cstat=0:bstat=0
 goto  [back]
 [circledra]
 if cstat=0 then cstat=1 else cstat=0
 if cstat=1 then lstat=0:bstat=0
 goto [back]
 [squaredraw]
 if bstat=0 then bstat=1 else bstat=0
 if bstat=1 then lstat=0:cstat=0
 goto [back]
 [HELPME]
 #h.4 "cls;place 10 30;down;backcolor 120 130 125;color white;fill 120 130 125"
 if hmn> 8 then hmn=0
 if hmn=0 then #h.4 "\Type commands like:             down;color green;line 100 100 200 200;circle 100"
 if hmn=1 then #h.4 "\ USE ARROW KEYS TO SCROLL UP AND DOWN THE EDITOR-"
 if hmn=2 then #h.4 "\<ENTER> does a line return and auto runs and updates draw."
 if hmn=3 then #h.4 "\ Dont forget to type 'down' at the start of your code and dont forget a 'color'"
 if hmn=4 then #h.4 "\ Use your Left Mouse Button activate areas you need to use"
 if hmn=5 then #h.4 "\ When you click COMPILE it saves to 'A draw in basic.bas'"
 if hmn=6 then #h.4 "\ When you click on SAVE it saves to 'A Notbasic.bas'"
 if hmn=7 then #h.4 "\ The COMPILER makes draws with #h.1 on each line. Make your graphics box same"
 if hmn=8 then #h.4 "\ the semicolon can separate many commands: 'backcolor green;fill green;cls'"
 hmn=hmn+1
 goto [back]
 [Error]'
  notice "YOUR ERROR IS: ";li$(lin);"..Try again "
'  empty the string so its no longer an error
  txt$=""
  li$(lin)=""
errstate$="yes"
Resume
end
[mouseloc]
#h.3 "down;color black;backcolor black;place 10 310"
#h.3 "\Left click was at ";constx;",";consty
#h.3 "down;color white;backcolor black;place 10 310"
constx= MouseX
consty= MouseY
call runit
#h.3 "\Left click was at ";constx;",";consty
if lstat=1 then currdraw$= "line "+str$(constx)+" "+str$(consty)+" "+str$(consth)+" "+str$(constv)
if bstat=1 then currdraw$= "line "+str$(constx)+" "+str$(consty)+" "+str$(consth)+" "+str$(consty)+";"+"line "+str$(consth)+" "+str$(consty)+" "+str$(consth)+" "+str$(constv)+";line "+str$(consth)+" "+str$(constv)+" "+str$(constx)+" "+str$(constv)+";line "+str$(constx)+" "+str$(constv)+" "+str$(constx)+" "+str$(consty)
if cstat=1 then currdraw$= "place "+str$(constx)+" "+str$(consty)+";ellipse "+str$(consth)+" "+str$(constv)
print #h.1, "down;color white;";currdraw$
goto [back]
[rmouseloc]
#h.3 "down;color black;backcolor black;place 10 290"
#h.3 "\Right click was at ";consth;",";constv
#h.3 "down;color white;backcolor black;place 10 290"
consth= MouseX
constv= MouseY
call runit
#h.3 "\Right click was at ";consth;",";constv
if lstat=1 then currdraw$= "line "+str$(constx)+" "+str$(consty)+" "+str$(consth)+" "+str$(constv)
if bstat=1 then currdraw$= "line "+str$(constx)+" "+str$(consty)+" "+str$(consth)+" "+str$(consty)+";"+"line "+str$(consth)+" "+str$(consty)+" "+str$(consth)+" "+str$(constv)+";line "+str$(consth)+" "+str$(constv)+" "+str$(constx)+" "+str$(constv)+";line "+str$(constx)+" "+str$(constv)+" "+str$(constx)+" "+str$(consty)
if cstat=1 then currdraw$= "place "+str$(constx)+" "+str$(consty)+";ellipse "+str$(consth)+" "+str$(constv)
print #h.1, "down;color white;";currdraw$
goto [back]

[compileit]
gfile$="A draw in basic.bas"
poz=0'
open gfile$ for output as #fil
while li$(poz)<>""
thestring$= li$(poz)
print #fil, "#h.1 ";chr$(34);thestring$;chr$(34)
poz=poz+1
wend
close #fil
goto [back]
end

[loadit]
gfile$="A Notbasic.bas"
poz=0'temporary variable for increment for array
REDIM li$(100)
if fileExists(DefaultDir$, "A Notbasic.bas") then
open gfile$ for input as #fil
while eof(#fil) > -1
input #fil, thestring$
 li$(poz)=thestring$
poz=poz+1
wend
close #fil
else
fexists$=""
end if
txt$=li$(0)
call runit
goto [inp]
end
function fileExists(path$, filename$)
   'dimension the array info$( at the beginning of your program
   files path$, filename$, info$()
   fileExists = val(info$(0, 0)) 'non zero is true
 end function

[saveit]
gfile$="A Notbasic.bas"
poz=0'  temporary variable for increment for array
open gfile$ for output as #fil
while li$(poz)<>""
thestring$= li$(poz)
print #fil, thestring$
poz=poz+1
wend
close #fil
goto [back]
end
[inp]'
   ch$ = Inkey$
   #h.2 "down;backcolor 180 180 180;fill 180 180 180;color blue"'
   c2$=left$(ch$, 1)
   if asc(ch$) >32 and asc(ch$)<127 then txt$=txt$+ch$
   if ch$=" " then txt$=txt$+" "
   if asc(ch$) =8 then sl= len(txt$)-1:s1$= mid$(txt$,1,len(txt$)-1):txt$= s1$:#h.2 "cls"
   if len(Inkey$)>1 then
        key1$=right$(Inkey$,1)
        key2$=left$(Inkey$,1)
    else
        key1$=Inkey$
        key2$=""
    end if
   ' print len(Inkey$),
    if key2$="" then print " ", else print asc(key2$),
    ch=asc(key1$)
    #h.2 "backcolor 150 150 150;fill 180 180 180 ;cls;color blue"

    if asc(ch$)= 13 then call runit'
      lpos0$= str$(lin-1)+"   "
    lpos1$= str$(lin)+"   "
    lpos2$= str$(lin+1)+"   "
      if lin>0 then print #h.2, "place 10 20;\";lpos0$;"";li$(lin-1)
#h.2, "place 10 40;\";lpos1$;"";li$(lin);"_"
    if lin<500 then print #h.2, "place 10 60;\";lpos2$;"";li$(lin+1)
    li$(lin)=txt$ ' this line will make issues if it is active
    if ch=37 then curs=curs-1
    if ch=39 then curs=curs+1
    if ch=38 then lin=lin-1
    if lin<0 then lin=0
    if ch=40 then lin=lin+1
    if ch$="(" then lin=lin-1
    if asc(ch$) =13 then if errstate$="no" then lin=lin+1
    if errstate$="yes" then errstate$="no"
    if lin>100 then lin=100'
    lpos0$= str$(lin-1)+"   "
    lpos1$= str$(lin)+"   "
    lpos2$= str$(lin+1)+"   "
    txt$=li$(lin)
    #h.2 "backcolor 180 180 180;fill 180 180 180;cls"'<<<<<<<<<<<<<<<<<<<<TEXT
    if lin>0 then print #h.2, "place 10 20;\";lpos0$;"";li$(lin-1)
    #h.2, "place 10 40;\";lpos1$;"";li$(lin);"_"
    if lin<100 then print #h.2, "place 10 60;\";lpos2$;"";li$(lin+1)
 '**************************
 goto [back]
 wait
sub runit
tl=0
#h.1 "place 0 0;down;cls"
[cyclerun]
if len(li$(tl))=0 then goto [getout]
#h.1 "down;";li$(tl)
tl=tl+1
goto [cyclerun]
[getout]
end sub
'
sub allclicked bttnHandle$
 r=r+5
 g=g+5
 b=b+5
 if r>255 then r=0
 if g>255 then g=0
 if b>255 then b=0
 call mixedcolor
 end sub
 sub minusallclicked bttnHandle$
 r=r-5
 g=g-5
 b=b-5
 if r < 0 then r=255
 if g < 0 then g=255
 if b < 0 then b=255
 call mixedcolor
 end sub
 sub redclicked bttnHandle$
 r=r+5
 if r > 255 then r=0
 call mixedcolor
 end sub
 sub blueclicked bttnHandle$
 b=b+5
 if b > 255 then b=0
 call mixedcolor
 end sub
 sub greenclicked bttnHandle$
 g=g+5
 if g >255 then g=0
 call mixedcolor
 end sub
 sub mgreenclicked bttnHandle$
 g=g-5
 if g<0 then g=255
 call mixedcolor
 end sub
 sub mblueclicked bttnHandle$
 b=b-5
 if b<0 then b=255
 call mixedcolor
 end sub
 sub mredclicked bttnHandle$
 r=r-5
 if r<0 then r=255
 call mixedcolor
 end sub
sub mixedcolor
 #h.3 "flush"
 #h.3 "place 120 80"
 #h.3 "down"
 rgb$= str$(r)+" "+str$(g)+" "+str$(b)
 #h.3 "color ";r;" ";g;" ";b
 #h.3 "backcolor "; rgb$
 #h.3 "ellipsefilled 100 100"
 #h.3 "place 10 10"
 #h.3 " color white"
 #h.3 " backcolor black"
 #h.3 "\The colors are ";r;" ";g;" ";b;"***"
#h.3 "flush"
end sub
'
sub screen x,y
nomainwin
WindowWidth=x
WindowHeight=y
UpperLeftX=1
UpperLeftY=1
global ch$
global txt$
global name$
global name1$
global getsizeh'
global getsizev
graphicbox #h.1, 0,0,949,450
graphicbox #h.2, 0,500,1200,600
graphicbox #h.3, 950,1,1200,450
graphicbox #h.4, 0,451,949,499
open "THE FIRST REAL TIME GRAPHICS IDE (USE MOUSE LEFT/RIGHT BUTTON TO CLICK ON WORK AREAS TO MAKE THEM WORK" for window_nf as #h
print #h, "trapclose [quit]"
print #h.1, "down;backcolor black;fill black"
print #h.2, "down;backcolor black;fill 180 180 180"
print #h.3, "down;backcolor black;fill black"
print #h.4, "down;backcolor black;fill 120 130 125"
end sub
 

« Last Edit: Sep 7th, 2016, 08:06am by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #1 on: Jan 18th, 2016, 05:49am »

Is there any reason to use graphicbox for text editing part instead of good old textbox?

As for now, it just don't work.
User IP Logged

damned Dog in the Manger
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #2 on: Jan 18th, 2016, 06:25am »

What do you mean it doesn't work?

I tested the program on windows 10 and windows 7..

And after long frustration work I decided to store the strings in string arrays..

The text refreshes on the graphics and I was going to see if I could maintain 3 lines at a time. Its a challenge..

Each line would be an array and I plan to make it so you can scroll up endlessly like in a normal editor (with only 3 lines showing at a time)...

Perhaps you can show me what you suggest in a small example..


User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #3 on: Jan 18th, 2016, 06:38am »

Quote:
What do you mean it doesn't work?

I tested the program on windows 10 and windows 7..

I tried to do
Quote:
place 100 100
circle 50

but Enter did not advance line, no responce from the program
Then I wrote it in a single line
Quote:
place 100 100; circle 50

again I got no responce on Enter
User IP Logged

damned Dog in the Manger
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #4 on: Jan 18th, 2016, 06:45am »

Solution:if you have no color it wont draw

it must be in this order:

Code:
place 100 100;color yellow;circle 50 


right now its in one line.. so its only good for as long as the command can be typed.
the above example should work

I tested it

And here is another example
Code:
place 100 100;backcolor green;color white;circlefilled 100 


« Last Edit: Jan 18th, 2016, 06:54am by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #5 on: Jan 18th, 2016, 07:02am »

Quote:
Perhaps you can show me what you suggest in a small example..

Heres' an old thread on another BASIC forum, discussing IDE for something alike.
Interactive JB, a tool for beginners?
« Last Edit: Jan 18th, 2016, 07:03am by tsh73 » User IP Logged

damned Dog in the Manger
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #6 on: Jan 18th, 2016, 07:06am »

Thanks for that Tsh..
I should have presented the instructions better so people would not assume a color was not needed.
I have highlighted the code examples in CODE sections and gave better instructions

Also the example looks good..

For challenge I still want to invent a way to make it all done nicely in the graphics boxes..

I want to show I can do it.

If the way I am doing it becomes too tedious I will switch to the text box.
« Last Edit: Jan 18th, 2016, 07:19am by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #7 on: Jan 19th, 2016, 01:15am »

Quote:
Perhaps you can show me what you suggest in a small example..

#2
the power of textbox ;)
Code:
'   Form created with the help of Freeform-J v.261006
'   Generated on Jan 19, 2016 at 09:08:23

    nomainwin

    WindowWidth = 560
    WindowHeight = 410

    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    statictext #main.statictext1, "Program", 6, 11, 144, 20
    texteditor #main.prog, 6, 31, 232, 160
    statictext #main.statictext3, "Log", 6, 196, 144, 20
    texteditor #main.log, 6, 211, 232, 145
    statictext #main.statictext5, "Graphic output", 254, 6, 144, 20
    button #main.button6, "RUN", [button6Click], UL, 174, 1, 64, 30
    button #main.button7, "CLS", [button7Click], UL, 478, 1, 64, 30
    graphicbox #main.gr, 246, 31, 300, 300
    menu #main, "File", "Exit", [onFileExit]
    menu #main, "Edit"    '<--- Texteditor Menu can be moved but not removed.

    menu #main, "Help", "About", [onHelpAbout]
    open "Graphic demo" for window as #main
    print #main.gr,"down; fill white; flush"
    print #main, "trapclose [quit.main]"

    print #main, "font ms_sans_serif 10"

    wait

[quit.main]
    Close #main
    END


[button6Click]
    'run the code
    #main.prog "!lines nLines"
    #main.log "executing ";nLines;" lines..."
    for i = 1 to nLines
        #main.prog "!line ";i;" aLine$"
        call execute aLine$ 'with error checking
        '#main.gr aLine$    'no error checking
    next
    #main.gr "flush"
    #main.log "ok"
    wait


[button7Click]
    #main.gr "cls"
    wait


[onFileExit]   'Perform action for menu 'File', item 'Exit'
    goto [quit.main]
    wait


[onHelpAbout]   'Perform action for menu 'Help', item 'About'
    notice "Graph demo"+chr$(13)+_
        "Reads a program"+chr$(13)+_
        "executes line by line"
    wait

sub execute aLine$  'for error checking
    on error goto [itHappens]
    #main.gr aLine$
    exit sub
    [itHappens]
    #main.log "err in line ";aLine$ 
end sub
 

sample program to paste into first textbox:
Code:
home
color black
font arial 10
\Hello there
\
font arial 15 bold
\Hello again
home
color red
circle 70
color green
size 2
place 100, 100
north
turn 90
go 100
turn 120
go 100
turn 120
go 100
turn 120
 
« Last Edit: Jan 19th, 2016, 01:41am by tsh73 » User IP Logged

damned Dog in the Manger
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT
« Reply #8 on: Jan 19th, 2016, 05:25am »

The above program has been replaced with a more recent version.

1) (UP/ DOWN) arrows can now scroll through code
2) 100 lines of code can be made (adjustable)
3) <ENTER> does carriage return and executes current line.. (must do this when you edit a line)
4) <ENTER> wont add empty spaces to a program...(that's good)



Your example is very compact VS my total reinvention of the graphics box usage for editor purposes.

Your example is also POWERFUL .. so I would need to reinvent A LOT if I did it my way.. But I am succeeding, so I may as well finish it for legacy sake.

I will most likely adopt your example in my future projects.

Because I may try to make a version of Basic that gets rid of the complexity..

IDEA- make a editor that gets rid of the need to understand DLL/ API and implement the 3D editor with very basic controls.

( I would need to understand them well to do this. And I probably would need help from others.. (MOST LIKELY)

I would like to finish the graphics text editor still because it hasn't been done before in Liberty. ( I could be wrong)

An actual functional graphics text editor that works with mouse cursor placement and (mid placement and edit) abilities may help in some future apps)

I have learned a lot about how an actual editor is displayed doing it how I am doing it. This is fun.


User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 936
xx Re: BEHOLD !! 1st Graphics IDE.. UPDATED JAN 19 20
« Reply #9 on: Jan 26th, 2016, 05:48am »

this may be useful :
- storing in a dynamik array

then there is no limit on your array
exept memory
Code:
''les 99e fifo lifo
''dynamic array

global cut$ , true , false
cut$ = "|"
true = not( false )
for i = 1 to 16
  number$ = push$( number$ , str$( i ) , false )
next i
print "numbers = " ; number$
print "numbers.size = " ; size( number$ )
number$ = remove$( number$ , "3" )
print "numbers.remove 3 = " ; number$ 
number$ = removeAt$( number$ , 4 )
print "numbers.removeAt 4 = " ; number$
number$ = removeAt$( number$ , -4 )
print "mumbers.removeAt -4 = " ; number$
number$ = insertAt$( number$ , "A" , 5 )
print "numbers.insert A @ 5 = " ; number$
number$ = insertAt$( number$ , "x" , -5 )
print "numbers.insert x @ -5 = " ; number$
number$ = insertSorted$( number$ , "13" , 1 , true )
print "numbers.insertSorted 13 1 true = " ; number$
q$ = top$( number$ )
print "numbers.top = " ; q$
print "numbers.element 5 = " ; bool$( element( number$ , "5" ) )
print "numbers.element 3 = " ; bool$( element( number$ , "3" ) )
print "numbers.reverse = " ; reverse$( number$ )
print "numbers.part 3 7 = " ; part$( number$ , 3 , 7 )
print "numbers.part -5 -2 = " ; part$( number$ , -5 , -2 )
print "numbers.suffle = " ; suffle$( number$ )
''print "numbers.sort 1 false = " ; sort$( number$ , 1 , false )



end
function bool$( x )
  if x then
    uit$ = "TRUE"
  else
    uit$ = "FALSE"
  end if
  bool$ = uit$
end function

function push$( stack$ , object$ , l )
  if object$ <> cut$ then
    if l <> 0 then
      push$ = object$ + cut$ + stack$
    else
      push$ = stack$ + object$ + cut$
      ''push$ = stack$ + cut$ + object$ 
    end if
  else
    push$ = stack$
  end if
end function

function pop$( stack$ )
''delete last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then pop$ = ""
''get right side of stack
  pop$ = mid$( stack$ , i + 1 , len( stack$ ) -i )
end function

function top$( stack$ )
''read last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then
    top$ = ""
  else
    top$ = mid$( stack$ , 1 , i - 1 ) '   <<<<<<<<
  end if
end function

function size( a$ )
  result = 0
  for i = 1 to len( a$ )
    if mid$( a$ , i , 1 ) = cut$ then result = result + 1
  next i
  size = result
end function

function insertAt$( a$ , item$ , i )
  p = 1
  result$ = ""
  max = size( a$ )
  if i < 0 then i = max + 2 - abs( i )
  while p < i
    result$ = push$( result$ , word$( a$ , p , cut$ ) , false )
    p = p + 1
  wend
  result$ = push$( result$ , item$ , false )
  while p <= max
    result$ = push$( result$ , word$( a$ , p , cut$ ) , false )
    p = p + 1
  wend
  insertAt$ = result$
end function

function insertSorted$( a$ , item$ , no , isStr )
  p = 1
  result$ = ""
  max = size( a$ )
  done = false
  while p <= max and not( done )
    m$ = word$( a$ , p , cut$ )
    mp$ = word$( m$ , no )
    ip$ = word$( item$ , no )
    result$ = push$( result$ , m$ , false )
    if isStr then
      if mp$ <= ip$ then
        result$ = push$( result$ , item$ , false )
        done = true
      end if
    else
      if val( mp$ ) <= val( ip$ ) then
        result$ = push$( result$ , item$ , false )
        done = true
      end if
    end if
    p = p + 1
  wend
  while p < max
    m$ = word$( a$ , p , cut$ )
    result$ = push$( result$ , m$ , false )
    p = p + 1
  wend
  insertSorted$ = result$
end function

function sort$( a$ , no , isStr )
  max = size( a$ )
  for i = 1 to max
    result$ = insertSorted$( result$ _
    , word$( a$ , i , cut$ ) , no , isStr )
  next i
  sort$ = result$
end function

function remove$( a$ , item$ )
  p = 1
  result$ = ""
  max = size( a$ )
  while p <= max
    if word$( a$ , p , cut$ ) <> item$ then
      result$ = push$( result$ , word$( a$ , p , cut$ ) , false )
    end if
    p = p + 1
  wend
  remove$ = result$
end function

function removeAt$( a$ , i )
  p = 1
  result$ = ""
  max = size( a$ )
  if i < 0 then i = max + 1 - abs( i )
  while p <= max
    if p <> i then
      result$ = push$( result$ , word$( a$ , p , cut$ ) , false )
    end if
    p = p + 1
  wend
  removeAt$ = result$
end function

function reverse$( a$ )
  p = 1
  max = size( a$ )
  while p <= max
    result$ = push$( result$ , word$( a$ , p , cut$ ) , true )
    p = p + 1
  wend
  reverse$ = result$
end function

function part$( a$ , b , e )
  max = size( a$ )
  if b < 0 then b = max + 1 - abs( b )
  if e < 0 then e = max + 1 - abs( e )
  for i = b to e
    r$ = push$( r$ , word$( a$ , i , cut$ ) , false )
  next i
  part$ = r$
end function

function element( a$ , item$ )
  p = instr( cut$ + a$ , cut$ + item$ + cut$ )
  element = p > 0
end function

function suffle$( a$ )
  max = size( a$ )
  dice = int( rnd( 0 ) * max ) + 1
  seed$ = word$( a$ , dice , cut$ )
  for i = 2 to max
    dice = int( rnd( 0 ) * ( max - i ) ) + 1
    p$ = word$( a$ , dice , cut$ )
    uit$ = push$( uit$ , p$ , false )
    a$ = removeAt$( a$ , dice )
  next i
  suffle$ = uit$
end function
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: BEHOLD !! 1st Graphics IDE.. Save/Load/Compile
« Reply #10 on: Feb 14th, 2016, 02:52am »

Update :
(1) error trapping
(2) auto run and update screen draws
(3) save and load your work
(4) you can compile your work into generic basic code.
(5) Mouse locator- makes it easy to place an object
(6) The code up top has been replaced with the new code.
(7) file exists is set up on load to prevent crash
« Last Edit: Feb 14th, 2016, 10:42pm by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: IDE with draw tools Special note:Sept 2016
« Reply #11 on: Sep 6th, 2016, 11:15pm »

Hello people!! Long time no chat. I am working on many projects, and will post some new content for many platforms soon.

This program requires that you are running Liberty in the sample LB file directory.
I have disabled the first line in case a person gets an error on start.
I stumbled on this today.
User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: IDE with draw tools Special note:Sept 2016
« Reply #12 on: Sep 7th, 2016, 01:59am »

Hello michael
Do you have code in first post updated? It is not clear from this post of yours.
If so please modify first post (add a line "updated <date>" somewhere near top, may be as a comment in the code)
« Last Edit: Sep 7th, 2016, 02:00am by tsh73 » User IP Logged

damned Dog in the Manger
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: IDE with draw tools Special note
« Reply #13 on: Sep 7th, 2016, 08:15am »

The problem is, when I was assessing this program for a future use, I noticed if I was outside the sample file directory, the ON ERROR would be triggered and I would be caught in an infinite error loop.
I had to make a note and disable the first line in case others would have this issue.

The program requires the Liberty BMP files to function properly.
The ON ERROR is meant to capture errors in the editor.

(you must press the UP/DOWN keys to change active editor line and you have 100 lines to work with.)

I could have edited it and left it where it was, but there was not enough room to leave sufficient note on the main post.

I will go over it carefully with my new skillset and try to improve its structure.

One way to improve it, is to do a file check for the BMP images that it uses for the buttons.

The problem with that approach, is it would require more coding, and there is no room, unless I use 2 posts, or attempt to use the cloud to link to the program, which I haven't tried yet. (I should.)

That would prevent the problem I noticed that would cause LB to get stuck in an inescapable ERROR loop.
I even tried KILL BASIC PROGRAMS, and it wouldn't break out of it.
( in which case I would have to restart my computer)
« Last Edit: Sep 7th, 2016, 08:43am by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14918
xx Re: IDE with draw tools Special note
« Reply #14 on: Sep 7th, 2016, 1:22pm »

on Sep 7th, 2016, 08:15am, michael wrote:
The problem is, when I was assessing this program for a future use, I noticed if I was outside the sample file directory, the ON ERROR would be triggered and I would be caught in an infinite error loop.
I had to make a note and disable the first line in case others would have this issue.

The program requires the Liberty BMP files to function properly.
The ON ERROR is meant to capture errors in the editor.

(you must press the UP/DOWN keys to change active editor line and you have 100 lines to work with.)

I could have edited it and left it where it was, but there was not enough room to leave sufficient note on the main post.

I will go over it carefully with my new skillset and try to improve its structure.

One way to improve it, is to do a file check for the BMP images that it uses for the buttons.

The problem with that approach, is it would require more coding, and there is no room, unless I use 2 posts, or attempt to use the cloud to link to the program, which I haven't tried yet. (I should.)

That would prevent the problem I noticed that would cause LB to get stuck in an inescapable ERROR loop.
I even tried KILL BASIC PROGRAMS, and it wouldn't break out of it.
( in which case I would have to restart my computer)


Best practice for a program would be to check if a directory exists within your code. Use the "files" statement. Check the documentation in the helpfile, or search LBPE or this forum for explanations and sample code.

The best place to share your programs is to create a page for yourself on the community wiki:
Community Wiki

Create a free account at wikispaces, request membership and add your contributions to the space.

User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls