|
Post by donnybowers on May 3, 2021 6:26:00 GMT -5
This is something that bothered me about RB for the longest time. I finally figured out how to wordwrap my pages simply by wrapping them in a <TABLE> with wordwrapping CSS on the <TD> as follows:
cssclass "td", "{width:100%; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word}"
html "<center><h1>Page Wrapped Paragraph</h1>" html "<table width=640 border=0><tr><td width=100%>"
html "16 For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life. 17 For God did not send His Son into the world to condemn the world, but that the world through Him might be saved. (John 3:16-17)"
html "</td></tr></table></center>"
Now if I could just find a way to do this with a TEXTAREA I'd be in business.
EDIT:
You don't need to tweak the program's CSS code as I did to get a TEXTAREA to wordwrap. StefanPendl shared a piece of code below that solves this problem I've been wrangling with for the past few years as follows:
for i = 1 to 10 text$ = text$ + "Hello world! " next
' set CSS id for line wrapping cssid #tawrap, "{white-space: pre-line;}"
textarea #box, text$, 40, 10
' apply CSS for line wrapping #box setid("tawrap")
print link #action, "Accept", [accept] wait
[accept] text$ = #box contents$() print print text$ wait
|
|
|
Post by StefanPendl on May 4, 2021 1:16:59 GMT -5
I use www.w3schools.com/ to look up anything related to HTML, CSS, etc. In addition any browser offers the ability to inspect an element through the context menu, just right-click on the text area in the browser and select inspect element from the context menu. When you know what kind of HTML element the text area is, you will be able to find the CSS it supports and how to wrap text.
|
|
|
Post by donnybowers on May 4, 2021 18:57:34 GMT -5
"the ability to inspect an element through the context menu" Wow! I never knew what "inspect element" was for. That info will definitely come in handy I'm sure. Thank you StephanPendi In regular HTML you don't have to define wordwrap in your styling. It's automatic in almost every element including the <BODY> itself. The only way regular text goes beyond the margins of the display in normal HTML is if you have it in a container that you've made to be wider than the display. Otherwise text wraps by default. At least that's how it works in every browser I've ever used.
I still haven't been able to figure out a way to get wordwrap in a TEXTAREA though. I've tried it in both the Windows and the Linux versions.
I use w3schools a lot. Also majorgeeks.com
|
|
|
Post by StefanPendl on May 5, 2021 0:40:03 GMT -5
A Run BASIC created page has a few predefined styles, so inspecting the element would give you some hint about what to do. The text area does have word wrap enabled by default, run the example below. for i = 1 to 10 text$ = text$ + "Hello world!" next textarea #box, text$, 20, 10 print link #action, "Accept", [accept] wait
[accept] text$ = #box contents$() print print text$ wait
At www.w3schools.com/tags/tag_textarea.asp a wrap attribute is listed, so there should be the ability to enable word wrap. At www.w3schools.com/tags/att_textarea_wrap.asp we are told that hard wrap needs the columns to be specified.
|
|
|
Post by donnybowers on May 6, 2021 2:30:14 GMT -5
A Run BASIC created page has a few predefined styles, so inspecting the element would give you some hint about what to do. The text area does have word wrap enabled by default, run the example below. for i = 1 to 10 text$ = text$ + "Hello world!" next textarea #box, text$, 20, 10 print link #action, "Accept", [accept] wait
[accept] text$ = #box contents$() print print text$ wait
At www.w3schools.com/tags/tag_textarea.asp a wrap attribute is listed, so there should be the ability to enable word wrap. At www.w3schools.com/tags/att_textarea_wrap.asp we are told that hard wrap needs the columns to be specified. I've been messing around with the CSS called "default.css" in the public folder. I got word wrap to work by changing the TEXTAREA as follows:
textarea { white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;}
The only downside is that the code editor now wordwraps also. Not a high price to pay though for this important feature. I'm working on a 32 bit Dell Inspiron laptop that I picked up for $25. I upgraded it from 1gb to 4gb memory. It doesn't have a hard drive, but it has a built in SD card slot so I'm using that to store my data and I'm trying to find the best lightweight live distro of Linux to do my programming on. I'm currently using a Linux Puppy called Bionic Pup and it seems to be working great so far for RB. I'm starting to get more enthused about RB since I discovered how to make the textarea element wordwrap. I believe there are workarounds for some of the other issues.
|
|
|
Post by donnybowers on May 6, 2021 2:42:28 GMT -5
I wonder if that wrap="hard" attribute found at www.w3schools.com/tags/att_textarea_wrap.asp would cause the text to be hard wrapped when saved to a file. I'll have to test if it will work in a textarea cssclass {wrap:hard;} one day and then save the contents to a file to see if it saves as hard wrapped text. That could be handy.
One of my big things is the ability to read in text submitted to a file and have it behave as a normal HTML page does with the word wrap when read back in and displayed on a page. The last thing I would want to have to do is reformat my documents with hard wraps just so that I can render them on a web page. Been there, done that back when I was only using JustBASIC and didn't have the ability to use API in my TEXTEDITORs. It can be very tedious.
In PHP you can take a normal document made with any text editor and include it in a web page and it will automatically wrap based on how you've laid out your page width. I prefer using a table or other container with a 100% width in my web pages (or maybe 90% centered on the screen. That way it works efficiently in virtually any browser. But I don't think that's possible in the current version of RB (though I may experiment a little more with the "standard.css" file in the public folder. The workaround is to use a common width like 640px and center that on the page so that it looks decent in almost any browser and in most screen resolutions. Most modern cell phones are at least 640px, but there are still some with as low as 320px. Most PCs have a screen width of at least around 1200 to 1400px or higher. That's where being able to set a container to a percentage of the screen width and center it on the screen really comes in handy. But, like I say, I've found a workaround that should work fairly well on most common devices.
|
|
|
Post by StefanPendl on May 6, 2021 23:24:11 GMT -5
I don't think, that the text formatting is changed using the hard word wrap for a text area when saved to a file. The wrapping is only applied to the display, not the contents. If you do not edit the default CSS file, but add a CSS entry to your program, things should be more dynamic without changing the RB IDE.
|
|
|
Post by donnybowers on May 7, 2021 0:29:52 GMT -5
I don't think, that the text formatting is changed using the hard word wrap for a text area when saved to a file. The wrapping is only applied to the display, not the contents. If you do not edit the default CSS file, but add a CSS entry to your program, things should be more dynamic without changing the RB IDE. I haven't been able to get a text area to do that without editing the standard.css file. I'm using the free version for Windows and the free version for Linux right now. Both in Virtualbox and on a separate machine that is 32 bit with a Puppy Linux on it. I haven't been able to get wordwrap to work in a textarea on any machine without tweaking the IDE's .CSS file. But another thing that you can do by editing the standard.css file is to set the width and height of the RB IDE textarea and it's font. This is especially helpful if you have a small, low resolution screen and the IDEs textarea goes beyond the display, which can be nerve racking. Also if you have a larger high resolution screen, making the font larger makes programming much more comfortable. But it's a good idea to make a backup copy of the original .CSS file just in case you really mess things up. You have to tweak it a bit because sometimes it doesn't necessarily behave as you would expect. But once you get it right it makes the whole experience much nicer. I'm thinking of having one copy of rbfree that I use for coding and one for testing and eventually for serving the code on the web (paid version). The one for coding won't have the word wrap and the one for testing and serving the apps will. I probably won't tweak the fonts on the server version, but I'll have to test my apps at different screen resolutions. Right now I'm on the learning curve, but once I get at least one app that I want to serve on the web I plan to get the actual web server. My plan is to do everything with no Java Script or at least as little of it as possible. I would like it to be purely BASIC. By the way, I looked at your web page yesterday Stephan. I don't know how you made that expanding menu list but I really like it. Are you using something like Java Script for that?
|
|
|
Post by donnybowers on May 7, 2021 1:38:27 GMT -5
For a test, I just renamed the original "standard.css" file from "standardX.css" back to "standard.css" and temporarily renamed my tweaked .CSS file to "standardN.css". When I refreshed the screen my textarea lost it's wordwrap. I don't believe you can make a textarea wordwrap in RB without tweaking the file named standard.css in the public folder.
If it can be done I would like someone to show me exactly how they're doing it. I've had more than one person give me some code that they said would make it wordwrap. I copied and pasted it into my RB IDE and it never worked for me even though it's basically the same code I'm using now with my tweaked standard.css file. What I'm doing now actually does what I need it to do.
If the RB site ever gets back up and running I would like to try my code there and see if it wordwraps. I've never tried this on an actual Windows machine that I can remember. It could be a Linux issue for all I know. I've been using a Windows XP virtual machine on my Linux machine and wordwrap doesn't work in a virtual XP running on Linux without my tweak. It works in a table <TD> and possibly in other container type elements, but not in a TEXTAREA element.
|
|
|
Post by StefanPendl on May 7, 2021 3:57:54 GMT -5
Have you tried the code I posted with an RB installation without any customization? It did word wrap for me in such a case. Could you post a sample that duplicates the issue or may be change the one I posted to duplicate the issue. You can have multiple RB installations on one host, you just need to change the port to one that is unique to the RB instance.
For the menu of my site I use a tiny JS script to toggle the visibility the rest is done in pure HTML and RB.
|
|
|
Post by donnybowers on May 7, 2021 13:33:08 GMT -5
Have you tried the code I posted with an RB installation without any customization? It did word wrap for me in such a case. Could you post a sample that duplicates the issue or may be change the one I posted to duplicate the issue. You can have multiple RB installations on one host, you just need to change the port to one that is unique to the RB instance. For the menu of my site I use a tiny JS script to toggle the visibility the rest is done in pure HTML and RB. I've been trying to get RB to wordwrap in RBfree for several years. It's the main reason I never purchased the paid version. I just dug up a Windows Vista computer that I forgot I had and tried your code above and it didn't wrap. I will be very disappointed to find out now after all these years that I should have purchased RB several years ago when it would still run on my main computer. I spent a lot of time, off and on, over the past several years trying to get wordwrap to work in a TEXTAREA in RB. Now this version is obsolete and you're telling me that wordwrap worked in the paid version all along? 2016: runbasic.proboards.com/thread/2084/get-java-script-work2019: runbasic.proboards.com/thread/2588/texarea-wordwrapAfter I found out I could make it wordwrap I immediately went on Facebook Marketplace and found an old 32 bit computer I can use as a server. I was all excited after years of being fascinated by RB and wishing it would wordwrap so that I could use it. Now I'm not sure what to believe about it. Are there other issues that no one tells you about when you ask?
|
|
|
Post by StefanPendl on May 8, 2021 3:21:40 GMT -5
I am using the paid release of Run BASIC. If I start RB and select Help => About Run BASIC... The release is displayed as follows:
What is your version?
I just did a simple test with my example, below find the results: - Internet Explorer has word wrap - Edge has no word wrap - Firefox has no word wrap
Also specifying the wrap CSS with the CSS class marks them as invalid.
|
|
|
Post by StefanPendl on May 8, 2021 4:20:30 GMT -5
The following now wraps in IE, Edge and Firefox:
for i = 1 to 10 text$ = text$ + "Hello world! " next
' set CSS id for line wrapping cssid #tawrap, "{white-space: pre-line;}"
textarea #box, text$, 40, 10
' apply CSS for line wrapping #box setid("tawrap")
print link #action, "Accept", [accept] wait
[accept] text$ = #box contents$() print print text$ wait
If you inspect the element, you can also change the CSS dynamically and this will only display CSS supported by the element.
|
|
|
Post by donnybowers on May 8, 2021 19:44:49 GMT -5
The following now wraps in IE, Edge and Firefox: for i = 1 to 10 text$ = text$ + "Hello world! " next
' set CSS id for line wrapping cssid #tawrap, "{white-space: pre-line;}"
textarea #box, text$, 40, 10
' apply CSS for line wrapping #box setid("tawrap")
print link #action, "Accept", [accept] wait
[accept] text$ = #box contents$() print print text$ wait
If you inspect the element, you can also change the CSS dynamically and this will only display CSS supported by the element. Eureka!!! Finally after all these years some wordwrap code that actually works. I tried it in IE, Firefox and Google Chrome and it worked! I don't have Edge but I'm glad to know it works in that one because it's probably one of the most used browsers today. Thank you, thank you, thank you.
|
|
|
Post by donnybowers on May 8, 2021 20:29:59 GMT -5
I am using the paid release of Run BASIC. If I start RB and select Help => About Run BASIC... The release is displayed as follows: What is your version? I just did a simple test with my example, below find the results: - Internet Explorer has word wrap - Edge has no word wrap - Firefox has no word wrap Also specifying the wrap CSS with the CSS class marks them as invalid. As I said in a previous comment, " I'm using the free version for Windows and the free version for Linux right now. Both in Virtualbox and on a separate machine that is 32 bit with a Puppy Linux on it." I wanted to start using RB years ago (and get the paid version) but no one seemed to be able to give me working code that would wordwrap the TEXTAREA. I tried a lot of different bits of code and nothing worked. It's amazing to me that this little short bit of code you gave me was the solution all along. Wordwrap was and is one of the few "must haves" that I needed before I could justify the purchase of RB. I've had the domain name for all these years (at least 5 years) and every now and then I play around with it in PHP, but I always wanted to create it in BASIC because it's so much easier (for me anyway). I don't really like PHP. It's not a very easy language to learn and I think it's kind of weird. Probably because I've always been stuck on BASIC. So I have to work through a way to do at least one other thing (I'm doing some preliminary testing of codes for various things that I will need to be able to do to create the site I want) and if I can find a way to do everything I need I intend to purchase RB (possibly both Windows and Linux versions). I already bought an old 32 bit laptop to put it on for my first server. If all goes well I may not be using LB as much any more. LOL! Thanks again for coming up with code that works for wordwrap! Here's me trying to find a solution for this 5 years ago. >> runbasic.proboards.com/thread/2084/get-java-script-work
|
|