[futurebasic] Re: [FB] Creating a Window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2004 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Sat, 9 Oct 2004 18:02:58 -0400
On Saturday, October 9, 2004, at 05:33  PM, Brian Heibert wrote:

> CASE UCASE$(LEFT$(lineStr,4)) = "WIN "   // doesn't work
> // WIN 1 5 5
> lft = MID$(lineStr, 5)
> mid1$ = MID$(lineStr, 7)
> lft1 = MID$(lineStr, 4)
> rt1 = MID$(lineStr,4)
> lfx = MID$(lineStr,3)
> lfx1 = MID$(lineStr,3)
> type = MID$(lineStr, 10)
>
>
> WINDOW #lft, mid1$, (lft1,rt1) - (lfx,lfx1), type
>
> All this code seems to do is put the editor window in the background 
> and
> nothing appears on top... How do I fix this?
>
> Brian Heibert
> NOT BOWERBIRD

  Have you verified absolutely that what you are getting out of your 
substrings are what you think you are getting? That's always Job 1.

The cheesy simple way to do this is like so:

lft = MID$(lineStr, 5)
mid1$ = MID$(lineStr, 7)
lft1 = MID$(lineStr, 4)
rt1 = MID$(lineStr,4)
lfx = MID$(lineStr,3)
lfx1 = MID$(lineStr,3)
type = MID$(lineStr, 10)

Open "A",#2,"TestResults,,System(_AplVol)
Print #2,lineStr
Print #2,lft
Print #2 mid1$
Print #2, lft1
Print #2, rt1
Print #2, lfx
Print #2, type
Close #2

Now open that file after you've run the program once and see that what 
you think you were getting is actually that.

And make sure that type is a string variable, or otherwise a VAL 
converting it to a numeric variable.

String$ = Text
Var = Numeric

type = VAL(MID$(lineStr, 10))

That's if type is dimmed as a long or int. If Type is a string, do 
yourself a favor (And us) and Dim it as type$

String$ from MID is going to be a String.  You need Val to convert to 
numeric. Unless some Fb pref mojo is set up I think.

If type is a mess, you will get a mess of a window.

Seems to me though that you are not going to be getting the right 
information back out of your string, you need to specify the starting 
point and the number of characters and adjust the starting point.

subString$ = MID$(string$,startPos [,numChars])

The simplest way to handle all this is to use a delimiter.

linestr = "0,0,500,300,ThisWindow, _docNoGrow"


r
c

// Cheap hack similar to that which is at the heart of a
// shareware beast I know to parse filter/action lines...

Local FN HandleLine$(incoming$)
DIM lgth%
DIM place%
dim leftBound,topBound,rightBound,bottomBound
Dim wndName$,type$

lgth       = LEN(incoming$)
place%     = INSTR(1,incoming$,",")
'~';
leftBound  = Val(left$(incoming$,place-1))
'~';
incoming$  = RIGHT$(incoming$,lgth-place)
lgth       = LEN(incoming$)
place%     = INSTR(1,incoming$,",")
'~';
topBound   = Val(left$(incoming$,place-1))
'~';
incoming$  = RIGHT$(incoming$,lgth-place)
lgth       = LEN(incoming$)
place%     = INSTR(1,incoming$,",")
'~';
rightbound = Val(left$(incoming$,place-1))
'~';
incoming$  = RIGHT$(incoming$,lgth-place)
lgth       = LEN(incoming$)
place%     = INSTR(1,incoming$,",")
'~';
bottomBound   = Val(left$(incoming$,place-1))
'~';
incoming$  = RIGHT$(incoming$,lgth-place)
lgth       = LEN(incoming$)
place%     = INSTR(1,incoming$,",")
'~';
wndName$   = left$(incoming$,place-1)
'~';
type$      = RIGHT$(incoming$,lgth-place)
'~';

Print leftBound,topBound,rightBound,bottomBound
print wndName$,type$

End fn

window 1

FN HandleLine$("0,0,500,300,Lovely Window Name, _docNoGrow")

do
handleevents
until 0