|
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.
|
|
|
Post by tenochtitlanuk on Aug 19, 2021 10:58:49 GMT -5
Code below is as used on three programs on my website to upload files on my local machine to my remote webserver. Works OK for me with LB under Linux/Wine. Can't remember who I got this from... Obviously you need to change the ftp address of your site and username/password.
nomainwin
dim error$(6000)
error$( 0) ="No problem.." error$(1003) ="user not connected to server" error$(1004) ="cannot open file" error$(1008) ="action not taken" error$(1010) ="server cannot open file" error$(3001) ="3001" error$(5002) ="5002"
WindowWidth = 100 WindowHeight = 40 UpperLeftX = 1 UpperLeftY = 1
port = 21 'port to use pasv = 1 'PASV mode? 1 is yes, 0 is no ftphost$ = "ftp.ddddddd.uk" 'ftp site address login$ = "plghplgh[" 'ftp site username login password$ = "plgh[plgh" 'ftp site password initpath$ = "" 'leave blank if you want the site's default 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
TRUE = 1 FALSE = 0
ftpsession = FALSE
open "LB" for window as #main
#main, "trapclose [quit]"
hW =hwnd( #main)
[upload] parentftp =hW '
open "ftp4w32.dll" for dll as #ftp
ftpsession = TRUE
calldll #ftp, "FtpInit", parentftp as long, res as long calldll #ftp, "FtpSetSynchronousMode", dummy as long calldll #ftp, "FtpSetDefaultPort", port as long, dummy as long calldll #ftp, "FtpSetPassiveMode", pasv as long, dummy as long calldll #ftp, "FtpLogin", ftphost$ as struct, login$ as struct, password$ as struct, parentftp as long, 0 as long, res as long calldll #ftp, "FtpCWD", initpath$ as struct, res as long calldll #ftp, "FtpSendFile", upload$ as struct, remotefile$ as struct, 0 as long, 0 as long, parentftp as long, 0 as long, res as long
wait
[closeftp] calldll #ftp, "FtpCloseConnection", dummy as long calldll #ftp, "FtpRelease", dummy as long close #ftp ftpsession = FALSE wait
[quit] close #main if ftpsession = TRUE then calldll #ftp, "FtpCloseConnection", dummy as long calldll #ftp, "FtpRelease", dummy as long close #ftp end if end
|
|
|
Post by tenochtitlanuk on Aug 13, 2021 3:33:41 GMT -5
I have no troubles either. LB has the 'exit' statement to cleanly leave structures like for/next.
This command causes the program to exit a looping structure such as DO, FOR, WHILE. It also causes the program to exit subs and functions.
|
|
|
Post by tenochtitlanuk on Aug 6, 2021 15:14:03 GMT -5
Bit like your avatar then, Brandon??
|
|
|
Post by tenochtitlanuk on Aug 6, 2021 11:49:20 GMT -5
Another couple of hours whiled away with LB. Our household is self-isolating for ten days because my wife is due a cataract op next week... so a bit of spare time!
One of those pictures you can just about persuade yourself you can make out
|
|
|
Post by tenochtitlanuk on Aug 6, 2021 4:41:07 GMT -5
Yup- as the screengrab shows it is the superposition of 500 trails starting at centre but with different random trails. ( Using the LB rnd() it does show the bias...
|
|
|
Post by tenochtitlanuk on Aug 5, 2021 6:47:38 GMT -5
I love how easy LB makes it to do coding tasks. My village were going to celebrate the end of lockdown restrictions with a summer fete, in open air, with various children's activities. I decided to do a variation on the traditional 'Pin the tail on the Donkey' by using not a donkey pictiure but a map of our village, and say that a treasure was hidden in a grid square. I never did trust blindfolded kids with pins in their hand- and it would be more educationally interesting! It took only about half an hour to perfect code that takes the map image and draws a grid and x/y references.
Since I wanted a big image I needed to tile it onto multtiple sheets of A4 and stick them together- again easy. The printing is easy, either by printing the tiles to my printer direct, or by saving as BMPs for putting on separate pages. The code below is one version when I was testing- I needed to go to more tiles for a bigger poster image for the final version. But then the weather forecast was so bad for the day that it has been cancelled!! Where has Summer gone??
EDIT I of course generate the winning square- a treasure box of sweets- in LB!
nomainwin
WindowWidth =1241 WindowHeight =1064
open "KSM map +grid" for graphics_nsb as #wg
#wg "trapclose quit" #wg "font 24 bold"
loadbmp "scr", "KSMmap.bmp" #wg "down ; drawbmp scr 53 53 ; size 2 ; flush"
for x =2 to 1250 step 49 #wg "line "; x; " 2 "; x ;" 1030" next x
for x =51 to 1151 step 49 #wg "place "; x +10; " 1020": #wg "\"; chr$( 64 +int( x /49)) #wg "place "; x +10; " 36": #wg "\"; chr$( 64 +int( x /49)) next x
#wg "color red"
for y =2 to 1080 step 49 #wg "line "; "2 "; y ; " 1227 "; y next y
for y =2 to 890 step 49 #wg "place "; 10; " "; y +85: #wg "\"; right$( " " +str$( int( y /49)), 2) #wg "place "; 1185; " "; y +85: #wg "\"; right$( " " +str$( int( y /49)), 2) next y
#wg "getbmp scr 1 1 1241 1064" bmpsave "scr", "griddedKSM0.bmp" #wg "print 1241"
#wg "getbmp scr 1 1 640 544" bmpsave "scr", "griddedKSM1.bmp"
#wg "getbmp scr 620 1 640 544" bmpsave "scr", "griddedKSM2.bmp"
#wg "getbmp scr 1 520 640 544" bmpsave "scr", "griddedKSM3.bmp"
#wg "getbmp scr 620 520 640 544" bmpsave "scr", "griddedKSM4.bmp"
wait
sub quit h$ close #wg end end sub
|
|
|
Post by tenochtitlanuk on Aug 1, 2021 11:20:29 GMT -5
Some further play using different sources of random decimal digits-- on my site
|
|
|
Post by tenochtitlanuk on Jul 29, 2021 5:43:34 GMT -5
I've run my LB version with LB's rnd(); with a million digits of Pi; and with a million-digit web download of random digits. You have to screensave/flush/redraw to avoid memory problems, but I'm happy with my colouring scheme- but not happy with the results using Pi nor LB's rnd(). Will put code up on my site soon- busy celebrating our Golden Wedding Anniversary at present!
|
|