|
Post by tenochtitlanuk on Aug 10, 2018 17:47:25 GMT -5
Currently adding a new webpage of examples of this kind of situation. Code up in a day or two..
|
|
|
Post by tenochtitlanuk on Jul 31, 2018 11:35:01 GMT -5
The link is on my original reply, but if it doesn't work for you go to www.diga.me.uk/IMdemonstration.htmlNote the code needs ImageMagic installing, and can crash LB if you don't have the source image in the directory you run the LB program from. The page linked above may have an updated version- I often modify code after further development and/or people's comments! You'll find all my LB pages on www.diga.me.uk
|
|
|
Post by tenochtitlanuk on Jul 29, 2018 15:35:34 GMT -5
|
|
|
Post by tenochtitlanuk on Jul 21, 2018 2:26:00 GMT -5
Indeed= you now are using an array.
In these kind of cases you could still have used a single string and extracted the VALUES of each digit if you wanted them as numeric digits... that's why I asked what you were wanting to do. The important thing is to know that digits in a number are not the same as characters in a string.
N$ ="08091960"
for i =1 to len( N$) print val( mid$( N$, i, 1)); " - "; next i
|
|
|
Post by tenochtitlanuk on Jul 20, 2018 11:52:31 GMT -5
You need to check what is meant by an 'array'. NEITHER of your variables is an array!
If you want to access each object in the middle of a single string variable you use 'mid$('. This will work for a string containing ANY character whether an alphabet letter, symbol or representaion of a digit.
E$ ="The quick brown fox jumps over the lazy dog"
N$ ="08091960"
for i =1 to len( E$) print mid$( E$, i, 1); " - "; next i
print
for i =1 to len( N$) print mid$( N$, i, 1); " - "; next i
An array would be something like name$( 100) which could hold up to 100 people's names- or score( 100) which could hold their score in a programming test!
There's also a useful command 'word$(', which can say fetch in turn each word in your example sentence.
If you find it confusing after looking them up in the help files, get back here and tell us what you are trying to do. We sll found it confusing when we started coding!
|
|
|
Post by tenochtitlanuk on Jul 7, 2018 10:01:43 GMT -5
Not sure if you want to first modify the file. If not, the easy way is as follows- input the whole file into a single string of binary data, and write it twice with the desired names. NB the ';' makes sure you do not add an extra CRLF at the file ends.
nomainwin
open "current_6.txt" for binary as #fileIn content$ =input$( #fileIn, lof( #fileIn)) close #fileIn
open "lines1.txt" for binary as #fileOut1 open "lines1.dat" for binary as #fileOut2 #fileOut1 content$; #fileOut2 content$; close #fileOut1 close #fileOut2
end
|
|
|
Post by tenochtitlanuk on Jun 29, 2018 2:07:28 GMT -5
Good to see you looking at this one, Jack. Have you now looked at the Rosetta Code link? The Perl example shows the best-explained optimisation, and very fast result... Moral- and reason for my posting- is that we should try always to analyse a programming task carefully before and durung coding- and be prepared to think laterally and even start again! The sledge hammer /brute force that computers allow is not always optimal!
|
|
|
Post by tenochtitlanuk on Jun 28, 2018 17:18:13 GMT -5
See the two types in action- colouring out from the centre.
|
|
|
Post by tenochtitlanuk on Jun 28, 2018 6:26:41 GMT -5
I'd encourage anyone to use floodfills if they enjoy colourful graphics. Other examples on my website
|
|
|
Post by tenochtitlanuk on Jun 27, 2018 16:16:25 GMT -5
Anatoly has explained and shown what I would have said. The 3 dimensions aren't the problem, its the sheer size. That's an awful lot of data- if you can give us an idea of what it represents we might think of a way. Perhaps store file of x,y data for every z value.. it depends whether the huge speed penalty of opening and closing files is offset- perhaps you only need to interrogate/change withein x.y plane at a fixed value of z?
|
|
|
Post by tenochtitlanuk on Jun 27, 2018 15:32:13 GMT -5
Here's a demo of the two- it either fills out to chosen boundary colour, over all other colours OR fills out for as long as it is on the chosen colour.
nomainwin
UpperLeftX = 10 UpperLeftY = 10
WindowWidth =530 WindowHeight =540
prompt "Enter 0 ( surface) or 1 ( border)"; response$ if not ( instr( "10", response$)) then end
type = val( response$) ' 0 for boundary, 1 for surface <<<<<<<<<<<<<<<< Change to try each fill type.. <<<
open "Fill-er-upper" for graphics_nsb as #wg
#wg "trapclose quit"
hw =hwnd( #wg) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< calldll #user32, "GetDC", hw as ulong, hdc as ulong ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#wg "down"
for i =1 to 50 r =int( 192 +64 *rnd( 1)) g =int( 192 +64 *rnd( 1)) b =int( 192 +64 *rnd( 1)) fillCol$ =str$( r) +" " +str$( g); " " +str$( b)
#wg "up ; goto "; int( 500 *rnd( 1)); " "; int( 500 *rnd( 1)); " "; int( 500 *rnd( 1)) #wg "color "; fillCol$ #wg "backcolor "; fillCol$ #wg "down ; circlefilled "; int( 50 +150 *rnd( 1)) next i
#wg "up ; goto 250 180 ; down ; color 0 0 120 ; circle 120 ; up"
x =250 y =250
calldll #gdi32, "GetPixel", hdc as ulong, x as long, y as long, pixcol as ulong bl = int( pixcol /( 256*256)) gr = int( (pixcol -bl *256*256) / 256) re = int( pixcol -bl *256*256 -gr *256)
c$ =str$( re); " "; str$( gr); " "; str$( bl)
#wg "color red" #wg "backcolor red"
notice "Watch the fill and where it goes out to.. it will fill red out from centre to the original" +_ " colour boundary, or to the circle outline, depending on your choice of 0 or 1. Run several times." +_ " NB this program fills FROM the centre ( 250, 250)"
x =250 y =250
if type =1 then targetcolor =120 *2^16 ' This is 120/256 blue. Colour = blue*2^16 +green *2^8 +red. calldll #gdi32, "ExtFloodFill",_ hdc as ulong,_ x as long,_ y as long,_ targetcolor as long,_ _FLOODFILLBORDER_ as long,_ result as long ' ie floodfill out until this targetcolor is met... <<<<<<<<<<<<<<<<<<<<<<<<<< else targetcolor =pixcol ' this is the border colour to be replaced up-to. Works OK. calldll #gdi32, "ExtFloodFill",_ hdc as ulong,_ x as long,_ y as long,_ targetcolor as long,_ _FLOODFILLSURFACE_ as long,_ result as long 'floodfill out wherever this colour is met... <<<<<<<<<<<<<<<<<<<<<<<<<< end if
'calldll #kernel32, "Sleep", 100 as long, ret as void' delay not needed here
scan
wait
sub quit h$ calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, ret as void 'release the DC <<<<<<<<<<<<<<<<<<<<< close #wg end end sub
|
|
|
Post by tenochtitlanuk on Jun 22, 2018 6:01:17 GMT -5
Browsing through Rosetta Code I found- ' Rosetta Code- Largest number divisible by its digits
' Find the largest base 10 integer whose digits are all different, ' and evenly/exactly divisible by each of its individual digits. ' ( Number must not include zero since division by zero is prohibited.)
' For example: 135 is evenly divisible by 1, 3 and 5.
I lashed up quick code late last evening ( no GUI needed here) and set it going. Then saw it was going to take ages. It in fact took near 12 hours!
Thinking more clearly I realised I'd missed various optimisations. DON'T read all the examples on RC- try to solve it yourself! Twelve hours SHOULD be easy to beat!
Don't post code, only time-to-solution. Then fastest person can post their code in say a couple of weeks!
|
|
|
Post by tenochtitlanuk on Jun 15, 2018 15:34:41 GMT -5
I've added a new page on my website that shows processing images into a rasterized form. Similar to my rasterbator-clone program.
I still think of myself as I looked 50 years ago, with my first SLR camera!
|
|
|
Post by tenochtitlanuk on Jun 14, 2018 15:36:45 GMT -5
|
|
|
Post by tenochtitlanuk on Jun 6, 2018 16:33:34 GMT -5
? Works for me. Hold left button down and you can draw in the right hand segment. Tap right for colour select to fill out from point selected and all its reflections/rotations. Edit N and kal as noted. But it doesn't seem obvious- the version I put on my site will be a later one if I have time.
I did originally create a light grey sector to show the drawable bit. Might put that back in. Your lines are equivalent in effect.
J
|
|