It is currently Tue May 23, 2017 1:50 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: convert html file to inline basic string
Unread postPosted: Sun Nov 08, 2015 9:03 pm 
Offline

Joined: Wed Apr 15, 2015 3:57 am
Posts: 437
If you want to embed an html file within your BASIC! code I think this works for
converting it to a string which can be loaded with HTML.LOAD.STRING

Just modify, run, copy and past the w$ string from index.bas output into your final program, or
INCLUDE index.bas if you prefer.



Code:
! convert html file to inline basic


TEXT.OPEN r,h1,"../data/index.html"  % input
f$ = "../source/index.bas"  % output

TEXT.OPEN w, h2, f$
TEXT.WRITELN h2, "w$=\"\""
TEXT.CLOSE h2

TEXT.OPEN a, h2, f$

DO
TEXT.READLN h1,a$
eof=(a$="EOF")
IF eof THEN D_U.BREAK
IF a$<>""
  a$=REPLACE$(a$,"\"","\\"+"\"")
  l$="w$+=\""+TRIM$(a$)+"\""
  TEXT.WRITELN h2, l$
ENDIF
UNTIL eof
TEXT.CLOSE h1
TEXT.CLOSE h2

GRABFILE s$,f$
PRINT s$



Sorry if someone already did this already... I am not very good at searching the forum yet.


Top
 Profile  
 
 Post subject: Re: convert html file to inline basic string
Unread postPosted: Mon Nov 09, 2015 5:07 pm 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2795
Location: Colorado, U.S.
Would the new ENCODE$(URL, , str$) function help with this? Or does that do too much (like %20 for space, etc.)?

The forum is not very good at searching the forum -- the forum search function is pretty terrible. A Google site search is better.

- Marc


Top
 Profile  
 
 Post subject: Re: convert html file to inline basic string
Unread postPosted: Tue Nov 10, 2015 5:25 am 
Offline

Joined: Wed Apr 15, 2015 3:57 am
Posts: 437
Not sure if I would need it... I am just experimenting with using inline html to see if it helps with app load times. I figure the less data files I need to copy on startup the better. Seems to work pretty well but I haven't done any benchmark tests.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred