[futurebasic] Re: [FB] Extra option-spaces in FB code

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2006 : Group Archive : Group : All Groups

From: Bernie <fb.mailing.list@...>
Date: Tue, 19 Dec 2006 22:51:51 +0000
Stu wrote:

> re Extra option-spaces in FB source code...
>
> Perhaps the FB compiler could be modified to treat option-space as  
> a regular space when it is not enclosed in quotation marks.  Might  
> this might be more work than worth.
>
> Plan B - Have an option in the editor to convert option spaces to  
> normal spaces (except when enclosed in quotation marks) similar to  
> option the remove leading spaces. Or maybe combine both features in  
> a 'Fix Spaces' option.
>
> I liked the short conversion program given by Bernie  
> (TwentyTwenty). Very good and quick example of file manipulation as  
> well. Note that as written it will convert ALL option-spaces (ASCII  
> 202) to spaces (ASCII 32), including those in quoted strings that  
> should probably remain as they were. Not a problem for the sample  
> used but some other time that may have unexpected effects.


Until either Plan A or Plan B happens, this small amend to  
TwentyTwenty ignores opt-space inside quotes (I think).

'----------
output "TwentyTwenty"

local mode
local fn Create2020File( spec as ^FSSpec )
'~'1
dim as FSSpec spec1, spec2
dim as Str255 s
dim as short i
dim as Boolean quoteOpen

spec1 = spec
spec2 = spec1
spec2.name = spec1.name + "[2020]"
def open "TEXTFB^e"
open "I", 1, @spec1
open "O", 2, @spec2
do
line input #1, s
quoteOpen = _false
i = 1
while ( i <= s[0] )
select s[i]
case 34 : quoteOpen = not quoteOpen
case 202 : if ( quoteOpen == _false ) then s[i] = 32
end select
i++
wend
print #2, s
until eof(1)
close
end fn


local mode
local fn DoFinderInfo
'~'1
dim as FSSpec spec
dim as OSType @ fType
dim as short @ count, action, j

count = 0
action = FinderInfo( count, spec, fType )
long if ( count > 0 )
for j = -1 to -count step -1
action = FinderInfo( j, spec, fType )
long if ( action == _finderInfoOpen )
if ( fType == _"TEXT" ) then fn Create2020File( spec )
end if
next
fn ClearFinderInfo
end if
end
end fn

on FinderInfo fn DoFinderInfo

poke long event-8, 0xFFFFFFFF
do
HandleEvents
until 0
'----------


BTW, FBtoC translates opt-space laden files without error.

Bernie