Geez Brian, Where to start...
1. When you are given a working function, try to copy and paste paste
it. It looks like you may have retyped the part that's still included
here below and in doing so, made some typos. Remember the earlier
advice of several to PROOFREAD your typing carefully. I spotted two
mistakes without looking very far.
a) keywocrd$ = LEFT$(dataline$,spacePosition-1)
- This should have 'keyword$' not 'keywocrd$'
b) CASE "PRINT;"
- You put in an extra semi-colon (;).
Maybe you've spotted them by now too and fix that. Hope so.
2. Use what is given and proven to work and don't add extras or keep
extra lines from before.
> // Obtain handle to selected edit field
> dim type,wd,wtype
> // Test for valid handle
- The above 3 lines are from your old code I think, not mine.
You're DIMming additional but unused variables.
> dim wnumx,wtx$
> dim wnumxNumber
>
> dim wnumx,wtx$
> dim wnumxNumber
- Here you are re-dimming some variables ( a no-no) as well as
DIMming 'wnumxNumber' which is noty used in my code, but was in your
previous attempt. Omit it.
Again, CHECK EVERY LINE in your program to see if it belongs. A
quick scan over the entire program shows several other similar
situations and potential problems. Similar case: In your FN doBreak,
what is the purpose of variable 'cancel'? It does not get any initial
value. It might get set to _zTrue. It is never used again. So why have
it? Or is there a missing instruction or two? Check it all to be sure
your program's logic is correct and complete in all parts.
You also need to order your code better. You have instructions that are
not in any FN's scattered all over the place - FB will treat them all
as part of the main program in the order they appear. Some might even
call your approach 'sloppy' since it is bits and pieces that are mixed
together without any apparent order.
A typical program might be like this.
a) Define all GLOBAL variables
- These will be values that are used in several FN's.
Define special constants
(ie for menus, items, buttons, edit fields, etc)
b) Define all action functions
(ie save a file, make a window, decode an instruction, etc)
-There normally is one FN per task.
c) Define all interface functions
(ie doMenu, doDialog, init (to make window, menus, fields, etc)
d) Set up the ON commands for interface events
e) Wait for events to happen...
DO
HandleEvents
UNTIL 0
Comment on your program's overall structure: You are doing far too
much in FN doMenu and FN doRUNcommand (or whatever it's called).
Example (again) in FN doMenu, use SELECT and CASE to decide which one
was chosen by the user; then go to a FN to perform that task. DO NOT
PUT ALL THE TASK'S INSTUCTIONS IN FN DoMENU - that just makes it
verrrry loooonnnnggg and hard to debug. A general rule is to try to
keep each function or task totally visible on the screen; that would be
20-30 lines. You've done that partly for the alert commands, but much
more can be done too.
Another comment: You seem to have borrowed a lot of code from various
places without understanding it completely or using it wisely. A simple
example of this: In one place you check to make sure the program is
running on at least OS-X 10.3 and then later you test to see if it's on
a MacPlus which never made it past System 6 or 7.
Always be sure you understand what a code segment does and why before
adding it to your program. And often adapt it for your particular
needs. When you upgrade a section, remove the old unneeded instructions
too to avoid confusion. This was hinted at in an example above but
bears repeating.
That's all for now. Maybe I'll put together a demo for you to show the
structure being discussed above. Oh yeah, that was done already, stage
by stage, last August. Time for a holiday instead. ;-)
Good luck,
- Stu
=============================================================
On Jan 12, 2006, at 7:34 PM, Brian Heibert wrote:
> Stu,
>
> I have switched over to using SELECT/CASE
> I have added two commands I haven't copied over the rest yet
> But there not working I get the Unknown Instruction on line #:1
>
>
> Local fn ParseEFLines( efID as long )
>
> // Obtain handle to selected edit field
> dim type,wd,wtype
> // Test for valid handle
> DIM efHndl&, dataLine$, lineNum
> DIM spacePosition
> DIM keyWord$, restOfLine$
>
> efHndl& = TEhandle( _cEdit )
> FOR lineNum = 1 TO efHndl&..TEnLines%
> dataLine$ = EDIT$( _cEdit, lineNum )
> spacePosition = INSTR(1, dataLine$+" "," ")
> keywocrd$ = LEFT$(dataline$,spacePosition-1)
> restOfLine$ = MID$(dataLine$,spacePosition+1)
>
> SELECT UCASE$( keyWord$ )
>
>
> CASE "WIN"
>
> dim wnumx,wtx$
> dim wnumxNumber
>
> dim wnumx,wtx$
> dim wnumxNumber
> wnumx = VAL( MID$(restOfLine,5) )
> wtx$ = MID$(restOfLine$,7)
> WINDOW wnumx, wtx$ // make the new window
> WINDOW _editor // and return to editor window
>
> CASE "PRINT;"
> nl$ = MID$(restOfLine$, 8)
> WINDOW OUTPUT wnumx
> PRINT nl$;
>
> CASE ELSE
> CALL PARAMTEXT ("UNKNOWN INSTRUCTION on line#:"+STR$(lineNum),
> dataLine$, "","")
> i = FN ALERT (128,0)
>
> END SELECT
> NEXT lineNum
> end fn
> ================================
< major snip >