|
Post by George on Apr 20, 2022 11:07:06 GMT -5
Been browsing all this stuff. It comes down to tweaking each and every one of the commands separately. The problem is that all the variables are stored as INSTANCE variables in the Profile Object, so it becomes impossible for external code (i.e. the command processor) to have any kind of tables pointing to the variables, since you can't access the INSTANCE variables from outside the object other than via their normal properties or methods. And you can't create CODEPTRs for properties or methods either.
So trying to merge a lot of this into one code block is a bust.
George
|
|
|
Post by George on Apr 20, 2022 15:12:31 GMT -5
Robert: QUERY is simple since it's only fetching info, so it's just a simple SELECT CASE. A common update routine would have to be much like this only with all the extra parse and validate code. It's really hard to justify.
George
SELECT CASE CONST$ UCASE$(gCmdOps(1)) ' See what we have CASE "ACTION" : DoErrorSetup(%eNone, "ACTION set to " + IIF$(Prf.ActionSave, FORMAT$(Prf.ActionSave), "OFF")) CASE "AUTOBKUP" : DoErrorSetup(%eNone, "AUTOBKUP set to " + IIF$(Prf.AutoBkup, "ON", "OFF")) CASE "AUTOCAPS" : DoErrorSetup(%eNone, "AUTOCAPS set to " + IIF$(Prf.AutoCaps, "ON", "OFF")) CASE "AUTONUMS" : DoErrorSetup(%eNone, "AUTONUM set to " + IIF$(Prf.AutoNum, "ON", "OFF")) CASE "AUTOSAVE" : wrd1 = IIF$((Prf.AutoSave AND %AutoSOn) <> 0, "ON ", "OFF ") wrd1 += IIF$((Prf.AutoSave AND %AutoSPrompt) <> 0, "PROMPT", "NOPROMPT") DoErrorSetup(%eNone, "AUTOSAVE set to " + wrd1) CASE "BOM" : DoErrorSetup(%eNone, "BOM write set to " + IIF$(Prf.BOM, "ON", "OFF")) CASE "BOUNDS" : DoErrorSetup(%eNone, "BOUNDS set to " + FORMAT$(Prf.BndLeft) + " thru " + IIF$(Prf.BndRight = 0, "MAX", FORMAT$(Prf.BndRight))) CASE "CAPS" : IF Prf.CapsDesired <> 2 THEN DoErrorSetup(0, "CAPS set to " + IIF$(Prf.CapsDesired, "ON", "OFF")) ELSE DoErrorSetup(0, "CAPS set to " + IIF$(Prf.CapsActual, "AUTO:on", "AUTO:off")) END IF CASE "CASE" : DoErrorSetup(%eNone, "CASE set to " + UUCASE(Prf.PCase)) CASE "CHANGE" : DoErrorSetup(%eNone, "CHANGE set to " + IIF$(Prf.ChangeMode = "D", "DS", "CS"))
CASE "COLLATE" : DoErrorSetup(%eNone, "COLLATE set to " + Prf.PCollate) CASE "COLS" : DoErrorSetup(%eNone, "COLS set to " + IIF$(Prf.Cols, "ON", "OFF")) CASE "EMACRO" : DoErrorSetup(%eNone, "EMACRO set to " + IIF$(Prf.EMACRO = "", "NONE", Prf.EMACRO + " " + IIF$(uucase(Prf.EMACRO) = Prf.EMACRO, "ON", "OFF"))) CASE "ENUMWITH" : DoErrorSetup(%eNone, "ENUMWITH set to " + FORMAT$(gEnumWith)) CASE "EOL" : Wrd1 = Prf.EOL IF VERIFY(Wrd1, $Hex) = 0 THEN Wrd1 = "X'" + Wrd1 + "'" DoErrorSetup(%eNone, "EOL set to " + UUCASE(Wrd1)) CASE "FOLD" : DoErrorSetup(%eNone, "FOLD set to " + IIF$(Prf.Fold, "ON", "OFF")) CASE "GLUEWITH" : DoErrorSetup(%eNone, "GLUEWITH set to: " + $DQ + ENV.GlueWith + $DQ) CASE "HEX" : DoErrorSetup(%eNone, "HEX set to " + IIF$(Prf.HexMode = 4, "ON", "OFF")) CASE "HIDE" : DoErrorSetup(%eNone, "HIDE set to " + IIF$(ISTRUE IsTPHideFlag, "ON", "OFF")) CASE "HILITE" : IF ISTRUE Prf.HiFind AND ISTRUE Prf.HiAuto THEN DoErrorSetup(%eNone, "HILITE FIND & AUTO both set to ON") ELSEIF ISFALSE Prf.HiFind AND ISFALSE Prf.HiAuto THEN DoErrorSetup(%eNone, "HILITE FIND & AUTO both set to OFF") ELSE DoErrorSetup(%eNone, "HILITE FIND set to " + IIF$(Prf.HiFind, "ON", "OFF") + _ ", AUTO set to " + IIF$(Prf.HiAuto, "ON", "OFF")) END IF CASE "IMACRO" : DoErrorSetup(%eNone, "IMACRO set to " + IIF$(Prf.IMACRO = "", "NONE", Prf.IMACRO + " " + IIF$(uucase(Prf.IMACRO) = Prf.IMACRO, "ON", "OFF"))) CASE "KB" : GOSUB KBQuery CASE "LRECL" : DoErrorSetup(%eNone, "LRECL set to " + FORMAT$(Prf.LRECL)) CASE "MARK" : DoErrorSetup(%eNone, "MARK set to " + IIF$(Prf.PMark, "ON", "OFF")) CASE "MINLEN" : DoErrorSetup(%eNone, "MINLEN set to " + FORMAT$(Prf.MINLEN)) CASE "NOTIFY" : DoErrorSetup(%eNone, "NOTIFY set to " + SWITCH$(ENV.NotifyLevelT = 0, "None", ENV.NotifyLevelT = 1, "Edit", ENV.NotifyLevelT = 2, "All")) CASE "NUMTYPE" : DoErrorSetup(%eNone, "NUMTYPE set to " + IIF$(Prf.NumType = "", "NONE", Prf.NumType)) CASE "PAGE" : DoErrorSetup(%eNone, "PAGE set to " + IIF$(Prf.PageFlag, IIF$(Prf.PageFlag = 2, "SCROLL", "ON"), "OFF") + IIF$(Prf.PageOffset <> 0, "/" + FORMAT$(Prf.PageOffset, "+#;-#"), "")) CASE "PRESERVE" : DoErrorSetup(%eNone, "PRESERVE set to " + IIF$(Prf.PPreserve = 0 , "OFF", IIF$(Prf.PPreserve = 1, "ON", "C"))) CASE "RECFM" : DoErrorSetup(%eNone, "RECFM set to " + Prf.RECFM) CASE "SETUNDO" : DoErrorSetup(%eNone, "SETUNDO set to " + FORMAT$(Prf.UndoNumber)) CASE "SOURCE" : DoErrorSetup(%eNone, "SOURCE set to " + Prf.PSource) CASE "START" : DoErrorSetup(%eNone, "START set to " + Prf.Start) CASE "STATE" : DoErrorSetup(%eNone, "STATE set to " + CHOOSE$(Prf.PState + 1, "OFF", "ON", "FEW", "MOST")) CASE "SUBARG" : DoErrorSetup(%eNone, "SUBARG is " + IIF$(ISNULL(Prf.SubArg), "OFF", Prf.SubArg)) CASE "SUBCMD" : DoErrorSetup(%eNone, "SUBCMD is " + IIF$(ISNULL(Prf.SubCmd), "OFF", Prf.SubCmd)) CASE "TABS" : DoErrorSetup(%eNone, "TABS set to " + IIF$(Prf.Tabs, "ON", "OFF")) CASE "XFORM" : DoErrorSetup(%eNone, "XFORM set to " + IIF$(Prf.XFormMac = "", "NONE", Prf.XFormMac + " " + IIF$(uucase(Prf.XFormMac) = Prf.XFormMac, "ON", "OFF"))) CASE "XTABS" : DoErrorSetup(%eNone, "XTABS set to " + FORMAT$(Prf.ImportTabs)) CASE ELSE : DoErrorSetup(%eFail, "Unknown QUERY operand: " + gCmdOps(1))
|
|
|
Post by George on Apr 20, 2022 17:16:06 GMT -5
The problem really comes down to using the string HEX. To get the current value, I have to fetch it via a call to the Object Property "Prf.HEX". But Prf.Hex as a property call is resolved at compile time, there is no "call by name" ability. No "call by name" is the big stumbling lock both for fetching and for updating the Prof value.
Objects are great - until they're not.
George
|
|
|
Post by Stefan on Apr 21, 2022 7:06:05 GMT -5
Guys,
This is clearly more involved than simply adding a TOGGLE Method to a bunch of Objects.
If memory serves, this came from not being able to simply TOGGLE the HIDE setting. The concept seems to have grown legs and run away out of control. There already is a way to determine the current setting, and a way to change it to what is needed.
Is it really worth expending a whole lot of effort and inventing new command syntax just to save the few keystrokes required to check and, if required, switch a few settings? How often is that really helpful?
While a simple way to TOGGLE all the ON/OFF settings might be nice, it isn't essential and clearly not 'so simple'.
Robert... "...Probably need some intermediate value, like: Convert ON to XON Convert OFF to ON Convert XON to OFF"
I think thinBasic even has a SWAP statement that might help here.
|
|
|
Post by George on Apr 21, 2022 9:56:00 GMT -5
Robert: In the sample QUERY code I posted, you can see QUERY fetching values via a Prf.variable call.
Prf is the object holding all the Profile values, variable is the name of the particular pvalue you want.
To change a value the code would be Prf.variable = new-value.
PowerBasic, based on the syntax of the usage, will determine whether Prf.variable is to call the PROPERTY GET variable or PROPERTY SET variable.
As I said, for normal SUB/FUNCTIONS you can build tables containing the code addresses of the routines using the CODEPTR function. Then you can do a CALL DWORD address to call the SUB/FUNCTION.
BUT - CODEPTR can not create an address for PROPERTY or METHOD routines, they are not in the same address space. So there is no way to create a table the way you'd like for a common routine. I.E. you cannot create:
Table: "HEX" CODEPTR(Prf.HEX) "AUTOBKUP" CODEPTR(Prf.AUTOBKUP)
etc. You have to, as QUERY does:
SELECT CASE CmdName
CASE "HEX": str = Prf.HEX CASE "AUTOBKUP": str = Prf.AUTOBKUP So your TOGGLE command would have to do the same thing as QUERY (a SELECT CASE) to get the values , then 'massage' it into a new command, and then either individually call the old original command within the select case, or perhaps have another table of Cmdnames and CODEPTRs to the old commands that can process the re-built command.
All in all a whole pile of work.
What I will consider is, for all the Profile type variables: * All will accept cmdname ? to display current status * All ON/OFF types will support no operands as a Toggle, and still support ON/OFF as operands * All NON-ON/OFF types will stay as they are (with the addition of ? support) * QUERY will be removed. George
|
|
|
Post by Stefan on Apr 22, 2022 7:55:21 GMT -5
Robert... " DIM TEST AS STRING = "FIRST OFF THEN ON" Now, use some kind of "swap" command to make the string contain "FIRST ON THEN OFF"
It's not that simple; I'd love to hear how you would do it."
Just for laughs( !)... (i'm just messing with you) It's probably cheating, but it does use SWAP
' Swapit.MACRO LOCAL AS NUMBER i LOCAL AS STRING old$ = "FIRST ON THEN OFF" LOCAL AS STRING wrd$(), new$ = "" PARSE(old$,wrd$," ") SWAP wrd$(2),wrd$(4) FOR i = 1 to 4 : new$ += wrd$(i)+" " : NEXT Halt(OK,"old=["+old$+"] new=["+Rtrim$(new$)+"]")
|
|
|
Post by George on Apr 22, 2022 10:20:23 GMT -5
Stefan: Don't even need a loop to rebuild the string, check out JOIN$
George
|
|
|
Post by George on Apr 22, 2022 10:35:15 GMT -5
Robert: Sorry, my changes will go ahead, QUERY is going away. As I'm doing it (after minor tweaking to some supporting functions) the code is much simpler for standard ON/OFF, Numeric operand or List types. e.g. AUTOBKUP (previously 8 lines of code) is now just 1:
METHOD pCmdAUTOBKUP(pCmd AS STRING) '---------- Turn AutoBkup ON or OFF or do a Query Prf.AutoBkup = GetOnOff(1, Prf.AutoBkup) ' Let GetOnOff do all the work END METHOD
George
|
|
|
Post by George on Apr 23, 2022 11:40:58 GMT -5
Robert: Q KB has moved to KEYMAP. i.e. KEYMAP Q string I figured KEYMAP was at least a logical place to stuff it.
George
|
|