[futurebasic] Window in Background Problem

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

From: Stu Cram <stu.cram@...>
Date: Tue, 12 Oct 2004 08:28:35 -0600
Hi again Brian,

Hope you've had time to review the functions MID$, LEFT$(), etc. I've 
included some code below that follows your method for parsing the 
'WIN ' instruction and making a window.

Your code seems to imply that each # is only one digit and a comma. 
Hovever, the window's position is given as 4 numbers and each can 
have several digits. That is why the program must find where each 
next comma is and extract the text before it.

In the sample code below, each item before a comma is found and 
stored in a variable (with an appropriate name for its use). Then 
that item is stripped from the start of the text and the process is 
repeated.

As you will see in the comments, the value of variable txt$ should 
get shorter and shorter by using MID$(). The leading item each time 
is obtained with LEFT$(). I've given a sample WIN command to 
illustrate the results as these instructions parse their way through 
it.

Note:  This is a 'brute force' way of doing the job and assumes the 
'WIN ' command is written correctly. If not, some errors are bound to 
occur without extra coding. My other approach given on Saturday is 
still my first recommendation.

Tip - Switch to the COURIER font to read this more easily.

'-------------------------------------------------------------------

CASE UCASE$(LEFT$(lineStr,4)) = "WIN "

// ex.  WIN 7,WELCOME,30,150,400,444,5
//   with commas to separate the items

' Variables used in this section...
' DIM txt$, b4$, p
' DIM wNum, wTtl$, wLft, wTop, wRt, wBtm, wType

txt$ = MID$(lineStr, 5 )     ' get rest of instruction after "WIN "

// now:  txt$ = "7,WELCOME,30,150,400,444,5"
p    = INSTR(1,txt$,",")     ' find position of comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wNum = VAL( b4$ )            ' convert to window # (7 in ex)
txt$ = MID$(txt$,p+1)        ' remove title from start of txt

// now:  txt$ = "WELCOME,30,150,400,444,5"
p    = INSTR (1,txt$,",")    ' find position of next comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wTtl = b4$                   ' store window title (WELCOME in ex.)
txt$ = MID$(txt$,p+1)        ' remove item from txt

// now:  txt$ = "30,150,400,444,5"
p    = INSTR (1,lineStr,",") ' find position of comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wLft = VAL(b4$)              ' store window title (30 in ex.)
txt$ = MID$(txt$,p+1)        ' remove item from txt

// now:  txt$ = "150,400,444,5"
p    = INSTR (1,lineStr,",") ' find position of comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wTop = VAL(b4$)              ' store window title (150 in ex.)
txt$ = MID$(txt$,p+1)        ' remove item from txt

// now:  txt$ = "400,444,5"
p    = INSTR (1,lineStr,",") ' find position of comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wRt  = VAL(b4$)              ' store window title (400 in ex.)
txt$ = MID$(txt$,p+1)        ' remove item from txt

// now:  txt$ = "444,5"
p    = INSTR (1,lineStr,",") ' find position of comma
b4$  = LEFT$(txt$,p-1)       ' extract item before comma
wBtm = VAL(b4$)              ' store window title (444 in ex)
txt$ = MID$(txt$,p+1)        ' remove item from txt

// now:  txt$ = "5"
// the last item doesn't have comma after it
wType = VAL(txt$)' store window title (444 in ex)

// old code - can be removed
'Lft=VAL(MID$(lineStr,5))
'Md$= STR$(MID$(lineStr,7))
'Sz1 = VAL(MID$(lineStr,2))
'Sz2 = VAL(MID$(lineStr,2))
'Sz3 = VAL(MID$(lineStr,2))
'Sz4 = VAL(MID$(lineStr,2))

// Revised way - with new variables from above...
WINDOW #wNum, wTtl$, (wLft,wTop) - (wRt,wBtm), wType

'----------------------------------------------------

HTH   (Untested, Hope there aren't any typos.)
-Stu
--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@...