Liberty BASIC Community Forum
« Search Results »

Welcome Guest. Please Login or Register.
Jan 23rd, 2018, 1:53pm


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

--Liberty BASIC Resources--
Liberty BASIC Community WikiSpace
Frequently Asked Questions
Bay Six Software Forum
Liberty BASIC Home Page
Carl Gundel's Blog
Official Liberty BASIC Support
Liberty BASIC Programmer's Encyclopedia
Liberty BASIC on Rosetta Code

Search Results

Total results: 10


 1   Liberty BASIC Code / Re: Extended ('infinite') precision calculations  on: Today at 12:51pm
Started by tenochtitlanuk | Post by CarlGundel
Here is an example that I posted on Yahoo as a response to the original poster. The longSci$() function returns an extended precision version of a floating point number. This is just the beginning of an ultimate solution because it only works with numbers between 0 and 1.

Please consider yourselves invited to extend it. ;)

-Carl

Code:
    global pad$
    pad$ = replstr$(space$(15), " ", "#")+"."+replstr$(space$(300), " ", "#")
    a=123456789
    for n=1 to -15 step -1
        b=a^n
        print n; tab(5);longSci$(b); tab(30); b
    next n
    end

function longSci$(value)
    shortForm$ = str$(value)
    if left$(shortForm$, 2) = "0." or left$(shortForm$, 3) = "-0." then
        offset = val(mid$(shortForm$, instr(shortForm$, "-")+1))
    end if
    longForm$ = using(left$(pad$, offset+16+15),value)
    longForm$ = trim$(longForm$)
    if instr(longForm$,"0.") = 1 then
       longSci$ = "0."+left$(mid$(longForm$, offset+3), 16)+"e-"+str$(offset)
       if value < 0 then longSci$ = "-" + longSci$
     else
       longSci$ = shortForm$
    end if
end function  

 
  Reply Quote Notify of replies

 2   Liberty BASIC Code / Re: Crossword  on: Today at 05:06am
Started by Sam67 | Post by Sam67
I had to modify a bit my first idea but I (I?) made it, the ACME (Average Crossword Maker Engine). Will make random pattern html grid as well as given pattern.
I'm happy. That's an interesting tool...rather toy actually.
Liberty Basic is really a great IDE! However an IDE refers to Something great in all langages. The Cradle of life would say Angelina.
That's a good beginning.
cheesy
 
  Reply Quote Notify of replies

 3   Liberty BASIC Code / Re: Wanting to use a loop, please help  on: Yesterday at 5:12pm
Started by Cor | Post by cor
A most elegant solution which works as hoped.

Thanks a lot for the speedy reply.
 
  Reply Quote Notify of replies

 4   Liberty BASIC Code / Re: Wanting to use a loop, please help  on: Yesterday at 3:28pm
Started by Cor | Post by tsh73
Handle Variable

start with Reply#3 - it might be enough.
 
  Reply Quote Notify of replies

 5   Liberty BASIC Code / Wanting to use a loop, please help  on: Yesterday at 3:18pm
Started by Cor | Post by Cor
Hello all,

I've been able to solve nearly all problems I've encountered using LB. But, I now have a problem I can only partially solve myself.

The code below will occur 15 times if I don't find a proper solution.
I can easily make line 1 (ARTIFACT01 through 15) suitable to operate in a loop. I just don't see how I need to modify line 5 (also ARTIFACT01 through 15). Any help will really be appreciated.

Cor

1 file$ = "L:\IDEASW\ARTIFACT01.ICO"
2 hBmp = LoadImgFromFile(file$)
3 if hBmp <> 0 then
4 loadbmp "pic", hBmp
5 print #main.ARTIFACT01, "drawbmp pic 0 0;flush"
6 unloadbmp "pic"
7 calldll #gdi32, "DeleteObject", hBmp as ulong, ret as ulong 'LB doesnt delete it for us.
8 end if
 
  Reply Quote Notify of replies

 6   Liberty BASIC Code / Re: backtraking tutorial  on: Yesterday at 11:55am
Started by bluatigro | Post by tsh73
better version, with real (??) backtracking
Code:
'' bluatigro 22 jan 2017
'' backtracking 2
'' maze solving
'' see for c++ :
'' https://www.geeksforgeeks.org/backtracking-algorithms/
global n
n = 0


global size
size = 3
dim maze(3,3),sol(3,3)
for y = 0 to size
  for x = 0 to size
    read a
    maze(x,y) = a
    sol(x,y) = 0
  next x
next y
''   maze
data 0,1,1,1
data 0,0,0,0
data 1,0,1,1
data 0,0,0,0
print "[ maze ]"
for y = 0 to size
  for x = 0 to size
    print maze(x,y) ;
  next x
  print
next y
if solve(0,0) = 0 then
  print "[ no solution ]"
end if
'else
  print "[ solution ]"
  for y = 0 to size
    for x = 0 to size
      print using(" ##",sol(x,y)) ;
    next x
    print
  next y
'end if
end

function solve( x , y )
  if x = size and y = size then 'destination reached
    n=n+1
    sol(x,y) = n
    solve = 1
    exit function
  end if
  if not(safe( x , y )) then exit function  'out of array

  n=n+1
  if free( x , y ) then 'free to move
    sol(x,y) = n
    if solve( x + 1 , y ) then
      solve = 1
      exit function
    end if
    if solve( x - 1 , y ) then
      solve = 1
      exit function
    end if
    if solve( x , y + 1 ) then
      solve = 1
      exit function
    end if
    if solve( x , y - 1 ) then
      solve = 1
      exit function
    end if
    'if no go - backtrack (it removes false thread)
    sol(x,y) = 0
  end if
  solve = 0
  n=n-1
end function
'---------------------
function safe( x , y )
  uit = 1
  if x < 0 then uit = 0
  if x > size then uit = 0
  if y < 0 then uit = 0
  if y > size then uit = 0
  safe = uit
end function

function free( x , y )
  uit = 1
  if maze(x,y) = 1 then uit = 0
  if sol(x,y) > 1 then uit = 0
  free = uit
end function
 

 
  Reply Quote Notify of replies

 7   Liberty BASIC Code / Re: backtraking tutorial  on: Yesterday at 11:43am
Started by bluatigro | Post by tsh73
I tweaked it until it runs on this small example.
I might be wrong.
Code:
'' bluatigro 22 jan 2017
'' backtracking 2
'' maze solving
'' see for c++ :
'' https://www.geeksforgeeks.org/backtracking-algorithms/
global n
n = 0


global size
size = 3
dim maze(3,3),sol(3,3)
for y = 0 to size
  for x = 0 to size
    read a
    maze(x,y) = a
    sol(x,y) = 0
  next x
next y
''   maze
data 0,1,1,1
data 0,0,0,0
data 1,0,1,1
data 0,0,0,0
print "[ maze ]"
for y = 0 to size
  for x = 0 to size
    print maze(x,y) ;
  next x
  print
next y
if solve(0,0) = 0 then
  print "[ no solution ]"
end if
'else
  print "[ solution ]"
  for y = 0 to size
    for x = 0 to size
      print using(" ##",sol(x,y)) ;
    next x
    print
  next y
'end if
end

function solve( x , y )
  n=n+1
  if x = size and y = size then
    sol(x,y) = n
    solve = 1
    exit function
  end if
  if safe( x , y ) then
    sol(x,y) = n
    if solve( x + 1 , y ) then
      solve = 1
      exit function
    end if
    if solve( x - 1 , y ) then
      solve = 1
      exit function
    end if
    if solve( x , y + 1 ) then
      solve = 1
      exit function
    end if
    if solve( x , y - 1 ) then
      solve = 1
      exit function
    end if
    'solve = 0
  end if
  solve = 0
  n=n-1
end function
function safe( x , y )
  uit = 1
  if x < 0 then uit = 0
  if x > size then uit = 0
  if y < 0 then uit = 0
  if y > size then uit = 0
 if uit = 0 then safe = uit: exit function  'cut if out of array
  if maze(x,y) = 1 then uit = 0
  if sol(x,y) > 1 then uit = 0
  safe = uit
end function
 

 
  Reply Quote Notify of replies

 8   API/DLL / Re: UDP comunications  on: Yesterday at 11:19am
Started by papa3110 | Post by papa3110
Great I still haven't finished the project I needed the UDP comms for


Thanks smiley

 
  Reply Quote Notify of replies

 9   API/DLL / Re: UDP comunications  on: Yesterday at 10:02am
Started by papa3110 | Post by Chris Iverson
Yeah, I'm putting it together, I just want to make sure the old code I have still works before posting it.
 
  Reply Quote Notify of replies

 10   Liberty BASIC Code / Extended ('infinite') precision calculations  on: Yesterday at 09:25am
Started by tenochtitlanuk | Post by tenochtitlanuk
Over the years I've had fun calculating beyond the intrinsic numeric accuracy of my languages' compilers/interpreters. It recently cropped up again on Yahoo forum.
For those who are interested, see my digame site. It has code for things like calculating the decimal expansion of fractions to your choice of significant figures....
 
  Reply Quote Notify of replies


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