Any idea how to flash text in browser?

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Any idea how to flash text in browser?

Post by sarossell »

I've been trying to do something that in the 1980s would be mind-numbingly simple but apparently is damn near impossible today.

I just want to be able to print flashing text. In the old days, you would just use the FLASH command or attribute. In the not too distant past, you could use the HTML <blink> tag. But today, even using HTML, JavaScript and sB code, I still can't get it to work.

Code: Select all

BROWSER "n" URL "test.html" AT 0,0 SIZE SCREEN_WIDTH(), SCREEN_HEIGHT()
This code resides in a file named test.html. It loads and prints the text, but there is no flashing. Any ideas? I'm stumped.

I can't take credit for the code:
http://www.computerhope.com/issues/ch001651.htm

Code: Select all

<!DOCTYPE html>
<html>
<head>
<script>
function blinker() {
	$('.blinking').fadeOut(500);
	$('.blinking').fadeIn(500);
}
setInterval(blinker, 1000);
</script>
</head>
<body>
<p class="blinking">This is an example of blinking text using JavaScript.</p>
</body>
</html>
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by GeorgeMcGinn »

This sounds like the job for a sprite.

Could a sprite be a series of ever brightening and dimming text instead?

Check in the examples of the knight running with a sword.

If it doesn't need to be in a browser, in theory this should work.

And the <blink> was always an MSIE tag as far as I recall and not fully supported by the W3C. (If it was, I never paid it or the marquee tag any thought at all).

George.
sarossell wrote:
Fri Jan 20, 2017 1:54 am
I've been trying to do something that in the 1980s would be mind-numbingly simple but apparently is damn near impossible today.

I just want to be able to print flashing text. In the old days, you would just use the FLASH command or attribute. In the not too distant past, you could use the HTML <blink> tag. But today, even using HTML, JavaScript and sB code, I still can't get it to work.

Code: Select all

BROWSER "n" URL "test.html" AT 0,0 SIZE SCREEN_WIDTH(), SCREEN_HEIGHT()
This code resides in a file named test.html. It loads and prints the text, but there is no flashing. Any ideas? I'm stumped.

I can't take credit for the code:
http://www.computerhope.com/issues/ch001651.htm

Code: Select all

<!DOCTYPE html>
<html>
<head>
<script>
function blinker() {
	$('.blinking').fadeOut(500);
	$('.blinking').fadeIn(500);
}
setInterval(blinker, 1000);
</script>
</head>
<body>
<p class="blinking">This is an example of blinking text using JavaScript.</p>
</body>
</html>
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by sarossell »

Actually, I was originally trying to do it with just sB code and regular text. There's a Rosetta task that asks the use to display a sentence and then highlight each word as it is spoken - kind of like Karaoke sub titles. I just think it's odd that I can't easily print "This word is highlighted" when I can just about approximate it in this forum! I'd prefer a filled box around the word though.
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Any idea how to flash text in browser?

Post by rbytes »

It took a bit of experimenting, but I got the CSS version to work.

This code is the program that does the browser display. You can name it anything you want:

Code: Select all

get screen size sw,sh
f$="Blink head"
for t=1 to 43
  FILE f$ READLINE temp$
  a$&=temp$
next t
b$="<p class="&"""tab blink"""&">This is an example of blinking text using CSS.</p>"
c$="<!DOCTYPE html><head>"&a$&"</head><body><H1>"&b$&"</H1></body></html>"
BROWSER "mine" AT 0,0 SIZE sw,sh
BROWSER "mine" text c$
This code is the CSS data. It should be named "Blink head" (no extender):

Code: Select all

<style type "text/css">
<!--
/* @group Blink */
.blink {
	-webkit-animation: blink .75s linear infinite;
	-moz-animation: blink .75s linear infinite;
	-ms-animation: blink .75s linear infinite;
	-o-animation: blink .75s linear infinite;
	 animation: blink .75s linear infinite;
}
@-webkit-keyframes blink {
	0% { opacity: 1; }
	50% { opacity: 1; }
	50.01% { opacity: 0; }
	100% { opacity: 0; }
}
@-moz-keyframes blink {
	0% { opacity: 1; }
	50% { opacity: 1; }
	50.01% { opacity: 0; }
	100% { opacity: 0; }
}
@-ms-keyframes blink {
	0% { opacity: 1; }
	50% { opacity: 1; }
	50.01% { opacity: 0; }
	100% { opacity: 0; }
}
@-o-keyframes blink {
	0% { opacity: 1; }
	50% { opacity: 1; }
	50.01% { opacity: 0; }
	100% { opacity: 0; }
}
@keyframes blink {
	0% { opacity: 1; }
	50% { opacity: 1; }
	50.01% { opacity: 0; }
	100% { opacity: 0; }
}
/* @end */
-->
</style>
Attachments
IMG_9409.JPG
IMG_9409.JPG (78.11 KiB) Viewed 3313 times
IMG_9410.JPG
IMG_9410.JPG (46.74 KiB) Viewed 3313 times
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by sarossell »

Wow! That worked a treat. Thanks! I had hoped it would not require such extensive coding for something that was so unbelievably simple 34 years ago. I appreciate you taking the time to work it out. I tested it and it worked perfectly (of course). Now I just need to read through it carefully to see what you did.

Just once, I wish someone could explain to me the benefit of requiring such a ridiculous amount of code to achieve something so mundane. On top of that, why that code should be cryptic and unintelligible to the common lay person without expending excessive amounts of time and energy to figure it out. On a 1982 Sinclair Spectrum, you literally only had to press two keys to set a flash attribute, enter the text to flash, and then two keys to set it back to normal print. Now, for some reason you have to know three languages (HTML, CSS, and BASIC), create two files, and enter 54 lines of code. That...is...ludicrous!

Still, much appreciated. :D
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Any idea how to flash text in browser?

Post by rbytes »

I hear you. It doesn't make sense at all.

Not only that, but when I tried to load and concatenate all of the CSS code into a single line, it still contained some invisible characters that caused syntax errors when I tried to create a$. The READLINE command ignores line feeds, so likely they were CHR$(13) carriage returns.

In graphics mode it is easy to flash text with a lot less code.

Code: Select all

GRAPHICS
FIELD 1 TEXT "Hi, Scott!" AT 100,100 SIZE 250,100
FIELD 1 FONT SIZE 50
DO
  FIELD 1 SHOW!PAUSE .5
  FIELD 1 HIDE!PAUSE .5
UNTIL 0
Attachments
IMG_9414.JPG
IMG_9414.JPG (68.35 KiB) Viewed 3305 times
IMG_9415.JPG
IMG_9415.JPG (51.84 KiB) Viewed 3305 times
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by sarossell »

That is a lot simpler! Considering the detailed font, color and placement control options with the graphics mode, perhaps it makes more sense anyway to do this graphically. If you can also incorporate interface functions like switches and sliders and such, then why not just treat text like a graphical element? I'm heartily encouraged. Thank you.
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by sarossell »

I originally imagined something like this.

Code: Select all

GRAPHICS
FIELD 1 TEXT "Hi, backatcha!" AT 100,100 SIZE 150,32
FIELD 1 BACK COLOR 0,0,0
FIELD 1 FONT COLOR 1,0,0
FIELD 1 FONT SIZE 20
DO
  FIELD 1 SHOW!PAUSE .3
  FIELD 1 HIDE!PAUSE .3
UNTIL 0
Now I just need to figure out how to effectively (and hopefully, easily) print a sentence with just one flashing word. I'm thinking I'll need to figure out how to assign a dynamically sized field based on the length of each word - most likely in the form of a function that takes a word as a parameter and determines the length of the field required to print just that one word.

This whole exercise came about from a regular learning thing I do when I try to learn a new programming language. I break out my old 1982 Sinclair computer manual and one-by-one replicate the functions in the new language to make sure I know how to use the protocols to achieve the same results. Most commands between BASIC versions are identical with few exceptions. But I eventually get to the point where I can either do all of the same functions in the new language or (as in the case with Swift and Python) decide it just isn't worth all the endless, cryptic coding to achieve it and then move on. That's why I just love smart BASIC. But FLASH and INVERSE eluded me until now.

I did this same thing to learn HTML and CSS. I learned it, found a way to achieve all of the old functions, and then promptly decided YUCK! and moved on. My go to backup BASIC is Liberty BASIC with it's free cousin Just BASIC and web-based sister Run BASIC. Unfortunately, they either only run on Windows (and I'm a hard and fast Mac guy by preference) or they can't compile.

I've gone through several other versions of BASIC with differing levels of disappointment; Gfa, Pure, Spider, Gambas, Xojo...But then when I came across smart BASIC, it all started to click. I finally found a new home after three decades. Now if there was a version of smart BASIC native to the Mac to compile Mac apps too, I would lose my mind! :shock: That would be my own personal Nirvana. I would pay good money for that!
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Any idea how to flash text in browser?

Post by rbytes »

There is so much potential in smart BASIC that I fear will never be realized. No doubt you saw the response I got from Mr. K. regarding seconding sB to another developer while working on SPL. He/she didn't even comment on the main point. And I find it odd that he never asks for high ratings like virtually every other developer does consistently. When any decision about sB is questioned, it's "my way or the highway." I would like to believe that Mr. K. is interested in growing her market base for sB, because then he might be open to introducing paid add-ons - e.g. an audio library, a 3D library, etc., to expand smart Basic. But I don't see much of a profit motive in her/his current modus operandi. I fear that some good programmers have departed because of it.

For a time I was a big fan of dark Basic from the U.K. It is a Windows Basic with powerful Sprite, 3D, animation and audio commands. I contacted the company that developed it and asked if they had any thought of bringing it to iOS. But no - they quickly replied to tell me that they just last year open-sourced it, and won't be actively developing or supporting it in future. They want to concentrate on game development. Sigh!

Are you familiar with th sB commands for calculating text size? They would be very useful for determining where to place your flashing text.
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Any idea how to flash text in browser?

Post by sarossell »

I assume you're referring to TEXT_HEIGHT() and TEXT_WIDTH(). I had forgotten about them, but looked them up again when you mentioned it. That sounds like the way to go. Thanks again!

I agree with you regarding the curious perspective with Mr. K's marketing and sales approach (or lack thereof). I'm not surprised however. To be a brilliant programmer AND a brilliant marketing strategist would warp the space-time continuum and the universe would have to find a way to destroy her for being too damn clever. Space abhors a vacuum, but the universe hates being outsmarted.

A lesson I learned early on in college is we all need help. But the "my way or the highway" attitude in conjunction with such amazingly prompt and helpful response in support seems a dichotomy of character. In America, we have this saying; "The customer is always right" because it's the customer's money that makes the decisions. But Mr. K has either been prevented or is unwilling or unable to market sB in a way that maximizes income. A sad state of affairs really. The Apple App Store was built to sell - and it works well. sB is an amazing product. But the market share appears to be too small in the current product configuration to garner more than just a few sales to justify such a low price (I'm assuming). If sB was pulling in the sales, I have to believe Elena would still be excited about updates and development. sB isn't her only product after all. This isn't her first rodeo, so to speak.

I've already decided that if we can't find the right financial incentive and marketing approach to convince her to continue and expand sB, I have no other choice but to look elsewhere to help support the development a competing product - and that would be a travesty. Surely, she must know that she's sitting on a potential goldmine that would take very little effort to pivot the marketing on a dual-product scheme that could be up and running in a very short period of time. She must also realize that she has at least four or five very motivated people on this forum who would be willing to help make it happen for little more than being allowed to do so. I am perfectly willing to put forth the effort to compile and edit a paperback and ebook manual to be sold on Amazon with proceeds going toward development costs. That in itself could support marketing efforts.

I firmly believe that the reason smart BASIC isn't bigger than it is currently lies in the fact that few people know about it. There has been an upsurge in interest in BASIC programming lately ever since the Brits came out with that $35 Raspberry Pi computer. They learned that kids trying to move from the graphical Scratch "language" to Python quickly became discouraged and gave up. BASIC has stepped in to fill that void and people are asking questions like "Well why didn't tell me about BASIC in the first place? When did this come out?" And when you tell them 1964, they suddenly get a new perspective on the world of programming.

It actually boggles my mind that this is even a question. You can program in BASIC and create Apple Store apps for Pete's sake!!! The only reason the world isn't going nuts for this is because they don't know it exists. :cry:
smart BASIC Rocks!

- Scott : San Diego, California

Post Reply