|
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
|
|
|
Post by tenochtitlanuk on Apr 11, 2023 13:30:54 GMT -5
Anatoly & I, among others, have written sets of complex operators. Complex numbers don't exist in LB so we pack the real and imaginary parts as a string with two part s, and write routines to display and manipulate them with all the usual operations. You could look at my pages at www.diga.me.uk/complexity.htmlwww.diga.me.uk/NRcomplexRoots.htmlI think tsh73 ( Anatoly) pit his routines up- was it on the #Programmer's Encyclopedia.
|
|
|
Post by tenochtitlanuk on Apr 6, 2023 3:49:10 GMT -5
Thanks for the hint, Chris. Always reliable on deep understanding! Yes, 'I' is 'image' ie send all bytes while 'A' sends as lines of 'A'SCII text and appropriate line endings for Linux/MS system.
The following seems to work-
if command$ ="upload" then type =asc( "I") calldll #ftp, "FtpSetType", type as ulong, res as long calldll #ftp, "FtpSendFile", upload$ as struct, serverFile$ as struct, 0 as long, 0 as long, parentftp as long, 0 as long, res as long:_ end if
Will edit this post if I find problems on transfers!
|
|
|
Post by tenochtitlanuk on Apr 4, 2023 18:01:59 GMT -5
Yup, sorry. 0D 0A replacing just 0A. Mea culpa /typo. I can set I or A mode from FileZilla but not from LB. Any ideas??
|
|
|
Post by tenochtitlanuk on Apr 4, 2023 10:39:36 GMT -5
I also notice that sending a file to the server then reading it back changes its length by 1 byte as the file which had chr$( 10) at the end now has chr$( 12); chr$( 10). I realise working on Linux and on Windows that they disagree on line endings, but I'm surprised that ftp up/down would alter the file itself! EDIT Looks like it was set to transfer as ASCII rather than binary??? FtpSetType This function changes the default transfer type.
Syntax: FtpSetType (char cType)
Argument: cType
new default transfer mode (either TYPE_A or TYPE_I)
But I'm not managing to change transfer type.. type$ ="I" ' A =ASCII, I =Image ie binary calldll #ftp, "FtpSetType", type$ as struct, res as long
|
|