|
Post by tenochtitlanuk on Mar 19, 2021 14:29:48 GMT -5
Actually I think you re confusind subs ( which are 'called' in LB) and gosubs, which end by returning.
Look at the example below- it creates a csv file whether called as a sub, or when called by trapclose.
Results are three files- and a screen display which closes. We're not exactly sure what the conditions are for your "BLANK" but this should give you an idea??
nomainwin
global p$ p$ ="Stay"
open "Demo" for text as #w ' so can see the generated terms..
#w "!trapclose QuitAndSave"
dim user$( 11, 6)
for i =1 to 11 for j =1 to 6 user$( i, j) =chr$( 65 +int( 26 *rnd( 1))) +chr$( 48 +int( 10 *rnd( 1))) #w user$( i, j) +","; next j #w "" next i
call QuitAndSave p$
p$ ="stillStay" call QuitAndSave p$
p$ ="Quitting"
wait
sub QuitAndSave p$ if p$ ="#w" then p$ ="Quitting" open "Settings_" +p$ +".csv" for output as #fOut for i = 1 to 11 for j = 1 to 6 #fOut user$( i, j) +","; next j #fOut chr$( 13); next i
close #fOut
if p$ ="Quitting" then close #w: end ' if we are really finishing... end sub
|
|
|
Post by tenochtitlanuk on Mar 19, 2021 7:32:01 GMT -5
Why do you not want to store them locally anyway? Your LB line has already temporarily stored them locally in a variable. Just save the downloaded images to files! Since they are large images, 24 bit, at 1828x100, you CAN show them in a graphic window. But you would probably want to resize them to fit a smaller window unless you have a very high res. monitor display. I use ImageMagick called from LB to do this kind of thing, but it's even easier to download them and resize to a standard size ( ie thumbnail) for LB to display.It's also easy to programmatically delete the downloaded image files.
myimage$ = HTTPGet$( "https://emea-presales.s3.eu-west-2.amazonaws.com/general/imagelib/image1.bmp") open "imageLocal.bmp" for output as #fOut #fOut, myimage$; close #fOut
|
|
|
Post by tenochtitlanuk on Mar 2, 2021 3:38:02 GMT -5
When I run your code it saves four files CALLED bmp, but actually jpegs! Didn't look further. LB4 can't directly load jpg.
|
|
|
Post by tenochtitlanuk on Feb 21, 2021 4:24:03 GMT -5
Well put Anatoly. Agree strongly with all your points...
EDIT' Many of my generation really got into programming on the BBC Computer. From the BBC computer manual..
-5 This shows one of the few ‘unary’ operators that we are used to. The - just acts on the 5 to make it a negative number.
|
|
|
Post by tenochtitlanuk on Feb 16, 2021 12:13:06 GMT -5
I needed some stick-on labels to customise this year's jam and marmalade production.
|
|
|
Post by tenochtitlanuk on Feb 16, 2021 11:19:32 GMT -5
It also throws the debugger.... try single-stepping through it.
|
|
|
Post by tenochtitlanuk on Feb 12, 2021 4:38:19 GMT -5
|
|
|
Post by tenochtitlanuk on Feb 8, 2021 4:16:50 GMT -5
You might be interested in a page on my LB site, where I was generating and displaying SVG files destined to drive my home-built EggBot. See Generating SVG files.
|
|
|
Post by tenochtitlanuk on Feb 7, 2021 11:18:47 GMT -5
Arrays need to be 'dimensioned' in advance- otherwise they default to 10 entries.
Try a line like this, early in the program...
dim setuparray$( 50)
|
|
|
Post by tenochtitlanuk on Feb 3, 2021 11:45:20 GMT -5
|
|
|
Post by tenochtitlanuk on Feb 2, 2021 18:21:28 GMT -5
That's a complex page on NBA, constructed without the data being in the page code, but fetched from a database.
Webpages are increasingly coded to customise them to you and convey data to you visually, but not to make it easy for you to get out what you want!
I used to run a LB program daily to download a synoptic weather chart. Now the equivalent page is built by tiling separate sections and MUCH harder to grab as a single image.
For fun I've written LB code that opens a texteditor. You MANUALLY click/drag through the NBA page's data section, and paste into the LB window, and it strips out the bits you want/don't want, and saves as a csv file. Seems to work fine...
LB could open that in a spreadsheet app of your choice.
Will put up code and how-to if it's any use to you. It gave me an hour or two of fun anyway!
|
|
|
Post by tenochtitlanuk on Jan 28, 2021 7:36:32 GMT -5
Nobody complained until now, Hmmm... I've mentioned it many times, on this site and the old one, including links to pages on my site explaining it! eg see middle of this page linked from a post on this forum. Don't get me wrong- there's no way I could write a language from intial specification to largely bug-free completion.I admire and sincerely recommend your creations, Carl, and realise you can't follow all our postings on the various wikis/boards/forums and websites like mine. You're still a saint for me!
|
|
|
Post by tenochtitlanuk on Jan 27, 2021 18:52:41 GMT -5
Yup -plenty of ways to make it unnecessarily slow!
Hadn't met Schlemiel before, but a relevant reference. Given that a sub using instr( can gallop through from the start counting delimiters faster than LB word$(, there has to be a weird algorithm in LB4.
Kernighan and Richie- yeah, part of my youth. I swear by The Wirth formula, 'Algorithms + Data Structures = Programs' is still valid. It is also complete. A program is nothing more than algorithms acting on data structures. And it won't optimise itself!
Also from the same era, Programming Proverbs in Pascal, and Programming in Forth. And the Cambridge programming book I still look at- with the examples in Fortran. ( that was my first exposure to a high level language- we had access to Cambridge's Titan, running an early ancestor of Fortran.
|
|
|
Post by tenochtitlanuk on Jan 27, 2021 16:12:36 GMT -5
The link is straight from Rosetta Code task ( rosettacode.org/wiki/Words_containing_%22the%22_substring ) which is trivial with fast word$(... web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt works fine for me. I've lived with the anomalous timing of LB's word$, and know how to get round it, and thought LB5 had it cracked- but it fails as I've noted on this long string dictionary- plain ASCII text with chr$( 10) separators. If you run my code you'll see the timings do not make sense- current version gave the following printout. How can it take so long to find a first word, and nearly the same for the last one??!! Searching started... MyWord$ found word # 1 to be <10th> taking 9 ms. MyWord$ found word # 1 to be <10th> taking 2 ms. LBword$ found word # 1 to be <10th> taking 14466 ms. LBword$ found word # 1 to be <10th> taking 15187 ms.
MyWord$ found word # 1 to be <1st> taking 5 ms. MyWord$ found word # 2 to be <1st> taking 20 ms. LBword$ found word # 1 to be <1st> taking 15830 ms. LBword$ found word # 2 to be <1st> taking 15813 ms.
MyWord$ found word # 1 to be <2nd> taking 4 ms. MyWord$ found word # 3 to be <2nd> taking 22 ms. LBword$ found word # 1 to be <2nd> taking 15835 ms. LBword$ found word # 3 to be <2nd> taking 15911 ms.
MyWord$ found word # 1 to be <9th> taking 26 ms. MyWord$ found word # 10 to be <9th> taking 25 ms. LBword$ found word # 1 to be <9th> taking 15847 ms. LBword$ found word # 10 to be <9th> taking 15832 ms.
MyWord$ found word # 1 to be <absence> taking 183 ms. MyWord$ found word # 100 to be <absence> taking 185 ms. LBword$ found word # 1 to be <absence> taking 15958 ms. LBword$ found word # 100 to be <absence> taking 15862 ms.
MyWord$ found word # 1 to be <annals> taking 1571 ms. MyWord$ found word # 1000 to be <annals> taking 1562 ms. LBword$ found word # 1 to be <annals> taking 15856 ms. LBword$ found word # 1000 to be <annals> taking 15915 ms.
MyWord$ found word # 1 to be <grandmother> taking 12931 ms. MyWord$ found word # 10000 to be <grandmother> taking 12908 ms. LBword$ found word # 1 to be <grandmother> taking 15865 ms. LBword$ found word # 10000 to be <grandmother> taking 16059 ms.
MyWord$ found word # 1 to be <windowpane> taking 73883 ms. MyWord$ found word # 100000 to be <windowpane> taking 75945 ms. LBword$ found word # 1 to be <> taking 21180 ms. LBword$ found word # 100000 to be <> taking 16356 ms.
Done. One bright spot- there are some very odd words in this dictionary- presumably scraped from some Unix documentation. Includes US cities/towns I'd never heard of!! But not Framlingham!!
|
|
|
Post by tenochtitlanuk on Jan 26, 2021 6:56:53 GMT -5
Revisited code showing the terrible behaviour of LB4 word$ on long strings.
The code below reads a large comma-separated dictionary ( available online- search for 'unixdict.txt' which is linked from Rosetta Code)
In LB4 my alternative 'MyWord$(' works as expected, and native LB4 'word$(' method takes ages..)
In LB 5 NEITHER work- they see the dictionary but fail to use the separator character I ask for...
Any ideas??
' OK in LB4 but fails in LB5 open "unixdict.txt" for input as #fIn ' ASCII text with chr$( 10) separator f$ =input$( #fIn, lof( #fIn)) close #fIn
print "Searching started..."
data 1, 2, 3, 10, 100, 1000, 9000
do read N now =time$( "ms"): print "MyWord$ found word # "; using( "######", N); " to be <"; MyWord$( f$, N, chr$( 10)); "> taking ", using( "######", time$( "ms") -now); " ms." now =time$( "ms"): print "LBword$ found word # "; using( "######", N); " to be <"; word$( f$, N, chr$( 10)); "> taking ", using( "######", time$( "ms") -now); " ms." print "" loop until N =9000
print "Done."
end
function MyWord$( source$, rank, sep$) ' get round LB4 word$( problem on large strings. if rank =1 then e =instr( source$, sep$) MyWord$ =left$( source$, e -1) else L =len( source$) p =0 rank =rank -1 do' p =instr( source$, sep$, p +1) rank =rank -1 scan loop until rank <=0 e =instr( source$, sep$, p +2) MyWord$ =mid$( source$, p +1, e -p -1) end if end function
|
|