Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Html to QB64 Quote Converter
#1
Ever get sick and tired of typing endless CHR$(34) additions to quoted text so it can be used in the IDE. Really, just me? Well I'll post this anyway.

Code: (Select All)
' Automatically adds quotes in correct places to convert html to QB64.
Width 20, 5: _Font 16: _ScreenHide
a$ = _Clipboard$
For i = 1 To Len(a$)
    If Asc(Mid$(a$, i, 1)) < 32 Then _Continue
    b$ = b$ + Mid$(a$, i, 1)
    If Mid$(a$, i, 1) = Chr$(34) Then b$ = b$ + " + chr$(34) + " + Chr$(34)
Next
b$ = "a$ = " + Chr$(34) + b$ + Chr$(34)
seed = 1 ' Adjust for alt = ""
Do
    c = c + 1
    q = InStr(seed, b$, Chr$(34) + Chr$(34))
    If q Then
        b$ = Mid$(b$, 1, InStr(seed, b$, Chr$(34) + Chr$(34)) - 2) + Mid$(b$, InStr(seed, b$, Chr$(34) + Chr$(34)) + 4)
    Else
        Exit Do
    End If
    seed = q + 3
    If c > 1000 Then Beep: System
Loop
If Right$(b$, 2) = " +" Then b$ = Mid$(b$, 1, Len(b$) - 2) ' Remove any trailing + sign.
_Clipboard$ = b$
System

So just compile and make a desktop shortcut. When you need to us it, just copy the text you want converted to your clipboard, click the short cut, and paste the converted results. Nothing will show up on your screen, it's all handled in the background.

PRINT CHR$(34) + "Pete" + CHR$(34)
Shoot first and shoot people who ask questions, later.
Reply
#2
I'm normally so lazy, that when it comes to something like this, I tend to just paste the evil code with quotes into a blank IDE window and then use Fine and Replace on it.

Find: "
Replace With: ''

Do all....

(and if that isn't obvious at first glance, that's a quote relaced with two colons " = '  ' )

So "Steve is Awesome" would convert to become ''Steve is Awesome''.



Since I often write my own word wrap routines like you do @Pete , I'll often just toss a simple conversion routine in there where those double colons translate to quotes, before printing/wrapping.
Reply
#3
But senior Steve...

I used to do the whole find replace bit, too.

Find: "

Replace: " + CHR$(34) + "

alt="Pete is tremendous"

becomes...

alt=" + CHR$(34) + "Pete is tremendous" + CHR$(34) + "

Helpful, but since the line doesn't include more text after the end quote, it needs the trailing + " cut off. My utility does that.

So with my utility

alt="Pete is tremendous"

becomes...

alt=" + CHR$(34) + "Pete is tremendous" + CHR$(34) 

Very easy to paste into

a$ = " alt=" + CHR$(34) + "Pete is tremendous" + CHR$(34)

Pete

- My best amigo is my ego!
Reply
#4
Aye.  I see what you're saying.  I'm just saying a lot of times, I'm lazy.  If I want to type:

PRINT CHR$(34) + "Hello World" + CHR$(34)

I'll just do a lazy:

WordWrap "''Hello World''"

And then the wordwrap function takes care of those double colons and converts them to quotes.  Wink

It's just one of those quick and simple little coding style things which I've adjusted to over the years, getting used to the quirks of the BASIC language.  Big Grin
Reply




Users browsing this thread: 1 Guest(s)