|
Post by tenochtitlanuk on Oct 20, 2021 17:16:18 GMT -5
Old hands will remember that LB4 turtle graphic moves go to an (integer) pixel and don't store the 'precise' value. In LB5, they retain the precise position but we don't yet have dll calls. When I add the fill routine, some of the figures do not close, and leak. In LB5 the new turtle does not suffer this problem. The graphic cycles through spiral-of-houses with LB4 with size =1 ( leaves gaps occasionally), with size =2 ( less neat, but tends to close the gaps), and with LB5 ( figures close, but can't be filled).
|
|
|
Post by tenochtitlanuk on Oct 18, 2021 16:50:58 GMT -5
Have to run this in LB5 to get the figures accurate and closing the path. Now add the fill..
|
|
|
Post by tenochtitlanuk on Oct 18, 2021 13:33:02 GMT -5
The turtle houses are begging me to add colour fill among other things...
|
|
|
Post by tenochtitlanuk on Oct 18, 2021 9:21:21 GMT -5
Agree- but easily written as functions. string$ can be defined with that name, but mid$ as a verb has to have a new name. Mid$ as a VERB, ie one that actions a change rather than reporting back part of a string, is implemented in various ways. In your example I assume you are using 15 bytes of the string as a standard-length field. A more common version would replace with however many are needed.
print string$( 40, "?") print insertMid$( "1234567890", 4, "Hi!")
end
function string$( n, c$) for i =1 to n string$ =string$ +c$ next i end function
function insertMid$( c$, p, n$) ' since 'mid$(' is a reserved keyword insertMid$ =left$( c$, p -1) +n$ +mid$( c$, p +len( n$)) end function
???????????????????????????????????????? 123Hi!7890
|
|
|
Post by tenochtitlanuk on Oct 17, 2021 11:27:59 GMT -5
Sure, add/use 'goto plus labels or line numbers'. I can't get worked up either for or against. But I don't want to debug other peoples' 'write once, read never' code with line numbers and 'goto' structures. Had enough of that in Forth- which is a language I love! As it happens I checked Rosetta Code for LB-unimplemented tasks today, and found a genetic code generate-and-mutate one. So I spent an hour happily doing it. rosettacode.org/wiki/Bioinformatics/Sequence_mutationYou generate a string containing only C, G, T and As, then apply mutation rules. I couldn't resist 'improving' the text-only answers in other languages with a colorful graphic- AND worked in two select/cases! As ever, I'll put my code up on my site in a day or two in case anyone fancies trying the task without preconceptions.Like perhaps an 'on/goto' version!!
|
|
|
Post by tenochtitlanuk on Oct 16, 2021 12:06:38 GMT -5
'Select Case' is so much clearer and powerful that I've never regretted the 'loss' of 'on...goto/gosub 1000,....'.
In the pre-line-label days the latter encouraged unreadable, spaghetti code. You had to look at line 1000 or wherever the jumps went to to find what was happening there- and when reading code you had no way when you got to line 1000 to know it was a jump target nor where it was coming from. Please do not resurrect it!
|
|
|
Post by tenochtitlanuk on Oct 10, 2021 3:56:56 GMT -5
Excuse the necroposting on an old thread! Anatoly's demo is a really good example of what can be done to produce display graphics. The code below uses the opposite approach- install and call GnuPlot from LB. Very short! You then have options like testing WITHOUT LB in the GnuPlot window; saving as Postscript or w.h.y. etc. Trumped by LB for the total versatility that coding in LB allows, but fast and easy, and GnuPlot has good documentation online. I work entirely on LB under Wine/Linux- perhaps because of this some of the axis titles etc are a bit displaced. nomainwin
exe$ ="C:\Program Files\gnuplot\bin\gnuplot.exe"
'run exe$ +" set sample 200" ' these get reset?? or ignored???? 'run exe$ +" set size square 0.8,0.9"
do while func$ <>"999" read func$ c$ =" -persist -e "; chr$( 34); " plot [-10.0:20.00] "; func$; chr$( 34) if func$ <>"999" then run exe$ +c$ loop
run exe$ +" -persist -e "; chr$( 34); " splot x**2 +y**2"; chr$( 34)
end
data "x" data "x**2" data "sin( x)" data "x *sin( x)" data "( sin( x) /x))2" data "exp( -x**2 /2)" data "( sin( x) /x)**2" data "sin( x) +sin( 3 *x) /3 +sin( 5 *x) /5)" data "sin( x) +0.2 *sin( 4 *x)"
data "999"
|
|
|
Post by tenochtitlanuk on Sept 20, 2021 9:28:50 GMT -5
I've used saving file contents to ramdisk for similar purposes in the past, usually between LB programs. This thread made me realise I'd never used saving to Windows clipboard before. This copies LB output to Windows clipboard.
nomainwin
open "Test" for text as #tWin
#tWin, "!trapclose [quit]"
#tWin "Hello World" +chr$( 13) +" Bye World!"
#tWin "!selectall" #tWin "!copy contents"
wait
[quit] close #tWin end
The opposite way, to copy from Windows clipboard to LB you'd use
#tWin "!paste"
|
|
|
Post by tenochtitlanuk on Sept 6, 2021 10:11:22 GMT -5
As another possible trap, is it happy with the space in
server$ = "smtp.freeolamail.net: 587"
|
|
|
Post by tenochtitlanuk on Sept 5, 2021 10:10:28 GMT -5
It does exactly the same as input$(1) if you are inputting from the keyboard. If inputting from a FILE you get its contents two characters at a time rather than one. See Help file and try its example with 1 and 2- you'll see no difference.
'read and display a file one character at a time 'accept characters and display them until Enter is pressed text$ = "" while c$ <> chr$(13) c$ = input$(1) print c$; if c$ <> chr$(13) then text$ = text$ + c$ wend print "You typed:"; text$ end
Now use a text editor to write a file "testMe.txt" containing say "Hello World". Make sure it has a multiple of two characters in it. Save it in the folder you saved the LB code in.
Change the LB code to
open "testMe.txt" for input as #fileIn text$ = "" c$ = ""
while c$ <>"!" c$ = input$( #fileIn, 2) print c$; " "; text$ = text$ +c$ wend
print "You typed:"; text$ close #fileIn
end
and run this version. You'll see two characters grabbed at a time.
Most common use is to grab ALL the characters in a file at once with..
allCode$ =input$( #fileIn, lof( #fIn))
|
|
|
Post by tenochtitlanuk on Sept 5, 2021 9:24:23 GMT -5
I edited the code to use my server and it ran happily for me.... BUT.... -you didn't notice, I suspect, my earlier comment that you need to surround subject and message string with quotes signs ( ") which is chr$( 34).
subject$ = chr$( 34) +"Plain text" +chr$( 34) message$ =chr$( 34) +"Hoorah or Oh, bugger!" +chr$( 34)
Try it again with these two lines corrected as above...
|
|
|
Post by tenochtitlanuk on Aug 31, 2021 16:47:49 GMT -5
sendEmail is very easy to use. Download this zip file which shows it used in a simple sub. You will need to unzip and save it to a folder for LB. Files are 'sendEmail.exe, an example file to attach, and the BASIC. Alter the lines to point to your mail server and its password, subject, message and attachment file. The chr$( 34) are quotes-signs, needed to wrap a line of text with spaces in it. Just run it. NB if the mail does not appear in your inbox, your spam filter has probably put it in the spam folder! Nigerian mail has a VERY bad reputation... Works fine for me, anyway... Caution, as before- your mail server password is going to be visible to anyone with access to the BASIC code...
|
|
|
Post by tenochtitlanuk on Aug 24, 2021 3:51:05 GMT -5
Not quite sure what you have available. DSAelectrical.com is obviously hosted on a server. It will accept ftp connections. If you want to try the e-mail +attachment route, have a look at one of my many LB pages e-mail sender
|
|
|
Post by tenochtitlanuk on Aug 23, 2021 7:38:33 GMT -5
Are you aware of how easy it is to send a graphics LB window to a printer to fill the width of the paper? If not, we can point you to the many examples- no printer ESC codes needed on modern printers.
EDIT Not trying to teach old hands things they know already! But it is so easy to write/draw to a graphics window. An all-singing/all-dancing dll is great and clearly works, but all my code needing paper output is drawn to screen then printed by LB. I know Anatoly and I have talked of a general-purpose LB packkage- but I always end up doing directly coded LB, or use say GnuPlot. See eg page-printing text & QR code
|
|
|
Post by tenochtitlanuk on Aug 21, 2021 14:42:03 GMT -5
Yes, ftp- 'file transfer protocol'- allows you to send a file from one computer to another over the internet. Almost all the code you can simply use as a blackbox. The lines you need to change are already commented and I add more detail below. For the method I gave, you need the file 'ftp4w32.dll' in the folder where your LB program is. You can download it via an internet search, or from my site at diga me!You won't need to alter these two lines- passive mode on port 21 is standard. port = 21 'port to use pasv = 1 'PASV mode? 1 is yes, 0 is no
If the file you wish to upload will be put into the remote computer's root folder you do not need to change initpath$. If you have a folder on the remote server called 'data' that you want the file to go into you's set initpath$ to 'data'. initpath$ = "" 'leave blank if you want the site's default
upload$ is the name of the file you want to upload from the directory holding the LB program. remotefile$ is what you want it called on the server. Usually these will both be the same name upload$ = "IOT.txt" 'full path & file info for file to upload remotefile$ = "IOT.txt" 'what you want it to be called on the ftp server. Yes, can be different to source name.
ftphost$ = "ftp.ddddddd.uk" 'ftp site address login$ = "plghplgh[" 'ftp site username login password$ = "plgh[plgh" 'ftp site password
ftphost$ will be 'ftp.DSAElectrical.com' or 'DSAElectrical.com'. Try both and see which works! Yes, your IT man will give you the username and password- if he trusts you! If not you COULD use a personal webserver- I pay for a server but you CAN set your own up locally- but you'd need to know how to make it visible outside your personal network. You don't need to understand the rest of the code. If the hostname, username and password are correct the file that was in the folder on your computer should now be in the folder on the remote server computer. If you now start a web browser and enter as url 'www.DSAElectrical.com/IOT.txt' ( or whatever name/pathname you chose) you should see the text file displayed. If you upload an image file it would be displayed. If it's zipped it should offer to unzip. If it doesn't know the file type it will offer to download it into your Downloads folder. I can't help much further- but your 'IT man' should understand what's going on... best of luck.
PS There is a small window which opens on your screen. It will self-close after a timeout, or you can click the close icon on it.
|
|