|
Post by tenochtitlanuk on Sept 12, 2023 6:20:39 GMT -5
I already commented three months back that it works in LB5 ( & RB)
The point is that this post was not made in the appropriate ( LB5) section of the forum, and did not make plain it is LB5-only. Confusing for people reading it... who may try the code only to be greeted immediately by error.
|
|
|
Post by tenochtitlanuk on Sept 11, 2023 16:20:50 GMT -5
Quick enquiry- this printing of a long string to file as given above won't work for me in JB nor LB4.5- under Wine/Linux. Am I missing something?? I've always had to print a series of shorter sections of the file and finish with a semicolon to ensure they concatenate.....
|
|
|
Post by tenochtitlanuk on Sept 1, 2023 10:08:10 GMT -5
I've been following the references to associated arrays and dictionaries- and Carl's dictionary example.
I dug up a demo program of mine which shows the benefit of hashing for such uses. This is where instead of filling an array sequentially, and then having to look through all entries until you find the one your key references, you can jump straight to it- or to very close- in one step. ( related to but separate from cryptographic use of hashing)
Still tinkering with the demo's webpage- but below is the sequence of filling from a data set about countries and populations, with examples of adding and deleting. Slowed down for display...
Will post link to the code and demo page in a day or two...
|
|
|
Post by tenochtitlanuk on Aug 14, 2023 6:28:17 GMT -5
nomainwin
WindowWidth =1000 WindowHeight = 650
open "Display" for graphics_nsb as #wg
#wg "trapclose quit"
#wg "down ; fill 180 180 180 ; size 4"
aveTerm =0
for i =1 to 140 newTerm =( -1 +2 *rnd( 0)) +10 *sin( i /10) aveTerm =aveTerm *0.75 +newTerm *0.25 #wg "color red ; set "; 10 +i *7; " "; int( 350 +20 *newTerm) #wg "color green ; set "; 10 +i *7; " "; int( 350 +20 *aveTerm) scan next
#wg "flush ; getbmp scr 1 1 1000 650" bmpsave "scr", "runningAveraged.bmp"
wait
sub quit h$ close #h$ end end sub
|
|
|
Post by tenochtitlanuk on Aug 14, 2023 5:12:31 GMT -5
|
|
|
Post by tenochtitlanuk on Jul 30, 2023 5:58:14 GMT -5
An example to give you some ideas... It asks the user for one input, then prints the response in a mixture of fonts colours and sizes. Screen shows Result then prints to the default printer. nomainwin
WindowWidth = 800 WindowHeight = 740
UpperLeftX = 100 UpperLeftY = 200
' Ask user for input prompt "Tell me your name"; response$ if response$ ="" then response$ ="tenochtitlanuk"
' Create and fill in the required text, numbers, etc open "Page for viewing, saving or printing" for graphics_nsb as #wg
#wg "trapclose [quit]"
#wg "down"
' Demonstrate random colours and backgrounds.. for i =0 to 9 #wg "up ; goto "; 10 +i *25; " "; 20 +i *60 #wg "down"
' Invent a random colour rf =int( 256 *rnd( 1)): gf =int( 256 *rnd( 1)): bf =int( 256 *rnd( 1)) #wg "color "; rf; " "; gf; " "; bf ' Set background to its inverse colour. #wg "backcolor "; 255 -rf; " "; 255 -gf; " "; 255 -bf ' Set font size ( and/or style or name) #wg "font "; int( 10 +50 *rnd( 1))
#wg "\"; " "; i; " "; response$; " " next i
' print the resulting screen at desired width on default printer. ' Here 1600 means my 800 fits half paper width #wg "flush" #wg "print 1600"
' Save image of page for records or furter use. #wg "getbmp scr 1 1 800 700" bmpsave "scr", "output.bmp"
wait
[quit] close #wg
end
|
|
|
Post by tenochtitlanuk on Jul 19, 2023 4:20:50 GMT -5
Do you know the 'Wayback Machine'? It's a project to keep scanning effectively all the worlds websites and save snapshots. Less practical now when most pages have become dynamic rather than static, but it has records for Alyce's site- and I downloaded the examples file from a copy of her site in 2018. PM me if you can't see how to do that...
|
|
|
Post by tenochtitlanuk on Jul 11, 2023 13:06:12 GMT -5
Works nicely once I added Nodejs to my Linux Mint set up.
I do like the ability in LB5 to accept continuous multi-line text. Hadn't realised it existed- I've always had to keep sending separate lines over and over in previous LB.
Nice to see you around here, meerkat...
|
|
|
Post by tenochtitlanuk on Jul 6, 2023 12:26:02 GMT -5
Yup. I did a similar test-
ifor i =1 to 1024 rd=gn=bl=int(rnd(1)*255) if rd =0 then print "0"; else print: print rd next
|
|
|
Post by tenochtitlanuk on Jul 5, 2023 11:57:37 GMT -5
Someone posting on Rosetta Code with a LB solution included the following line..
rd=gn=bl=int(rnd(1)*255)
Multiple attributions are available in some languages, written this way. Not in LB. What do you think LB makes of it...??
|
|
|
Post by tenochtitlanuk on Jun 10, 2023 11:36:39 GMT -5
Experienced programmers wouldn't make dogmatic statements about loop value on exit! In many BASICs and other languages the loop counter has local scope and is not available at all outside the loop. In others you may find the external value on exit is the loop-limit, or one bigger.
Hence Google ( for example) wisely quotes things like...
It's also generally recommended against using "i" after you exit the loop in most coding standards I have ever read.
You're on your own too if you change say x to 2 ( or 200!) inside the loop.
LB 4 and 5 do have graceful exit from for/next if needed.
It's worth reading Wikipedia..
Loop variable scope and semantics Different languages specify different rules for what value the loop variable will hold on termination of its loop, and indeed some hold that it "becomes undefined".
|
|
|
Post by tenochtitlanuk on Jun 1, 2023 15:05:54 GMT -5
Perhaps I should do a version using Cyrillic ( Russian) characters?? Run my current LB program code for this suggested Rosetta Code task and it puts this up on a browser screen.
I was quite pleased- but just noticed I have several mistakes to correct! Will change the relevant page on my LB site... however the code is messy and I should really re-write from scratch.
|
|
|
Post by tenochtitlanuk on May 26, 2023 7:15:27 GMT -5
Just as an aside, and possibly a challenge to fellow coders... a nice bit of string manipulation, that LB is very good at. There is a suggested Rosetta Code task to 'transliterate' some English text to a Greek alphabet version, using the sounds of each Greek letter correctly.However there are a few cases where two letters in English are represented by one in Greek- eg 'theta'. And a special rule for an s at the end of a word taking a different form of 'sigma'. Unfortunately LB4 does not handle Unicode so can't display the characters- so I use LB to call a web browser and use the html codes like 'α'- alpha. The target text is The quick brown fox jumped over the lazy dog.
I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang. As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio.
sphinx of black quartz, judge my vow. and the output should look like Will put a page up with my ( messy) solution in a few days. I'm getting time back for some coding after moving house....
|
|
|
Post by tenochtitlanuk on Apr 21, 2023 10:20:27 GMT -5
Looks like a simple spelling error- you put 'geuss' in
if geuss < guessMe then ...and should be 'guess'.
|
|
|
Post by tenochtitlanuk on Apr 15, 2023 15:05:57 GMT -5
|
|