mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-05 01:50:25 +00:00
Implements setting value of arrays/UDTs.
This commit is contained in:
parent
da1344221f
commit
d62e307126
|
@ -318,7 +318,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
|
|||
ELSEIF vw_varType$ = "STRING" THEN
|
||||
vw_varSize = LEN(vw_dummy%&)
|
||||
END IF
|
||||
'this is where we calculate the actual element position in memory
|
||||
'this is where we calculate the actual array index position in memory
|
||||
IF vw_arrayelementsize = 0 THEN
|
||||
vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_varSize)
|
||||
ELSE
|
||||
|
@ -396,13 +396,50 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
|
|||
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass
|
||||
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass
|
||||
|
||||
IF vw_isarray = 0 AND vw_isUDT = 0 THEN
|
||||
'--------
|
||||
IF vw_isarray THEN
|
||||
vw_lbound = check_lbound%&(vw_address)
|
||||
vw_ubound = check_ubound%&(vw_address)
|
||||
|
||||
IF vw_arrayIndex < vw_lbound OR vw_arrayIndex > vw_ubound THEN
|
||||
GOTO cmdProcessingDone
|
||||
END IF
|
||||
|
||||
'get the address of where this array's data is stored
|
||||
vw_buf$ = SPACE$(LEN(vw_dummy%&))
|
||||
vw_m = _MEM(vw_address, LEN(vw_dummy%&))
|
||||
vw_m2 = _MEM(_OFFSET(vw_buf$), LEN(vw_dummy%&))
|
||||
_MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET
|
||||
|
||||
IF LEN(vw_dummy%&) = 8 THEN
|
||||
vw_address = _CV(_INTEGER64, vw_buf$) 'Pointer to data
|
||||
ELSE
|
||||
vw_address = _CV(LONG, vw_buf$) 'Pointer to data
|
||||
END IF
|
||||
'vw_address now points to the actual data
|
||||
|
||||
'find the required element for this array
|
||||
IF INSTR(vw_varType$, "STRING *") THEN
|
||||
vw_varSize = VAL(MID$(vw_varType$, _INSTRREV(vw_varType$, " ") + 1))
|
||||
ELSEIF vw_varType$ = "STRING" THEN
|
||||
vw_varSize = LEN(vw_dummy%&)
|
||||
END IF
|
||||
|
||||
'this is where we calculate the actual array index position in memory
|
||||
IF vw_arrayelementsize = 0 THEN
|
||||
vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_varSize)
|
||||
ELSE
|
||||
vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_arrayelementsize)
|
||||
END IF
|
||||
ELSE
|
||||
IF vw_isUDT = 0 THEN
|
||||
IF INSTR(vw_varType$, "STRING") = 0 THEN
|
||||
'numeric variables need no further dereferencing
|
||||
GOTO setAddress
|
||||
ELSE
|
||||
setString:
|
||||
'vw_address now points to the qbs struct
|
||||
set_qbs_size vw_address, vw_varSize
|
||||
set_qbs_size vw_address, LEN(vw_value$)
|
||||
|
||||
vw_varSize = LEN(vw_address) + LEN(vw_varSize)
|
||||
vw_buf$ = SPACE$(vw_varSize)
|
||||
|
@ -417,9 +454,28 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
|
|||
END IF
|
||||
GOTO setAddress
|
||||
END IF
|
||||
ELSE
|
||||
'extra dereferencing required for arrays and UDTs
|
||||
END IF
|
||||
END IF
|
||||
|
||||
'if it's a UDT, move the pointer to this element's offset
|
||||
vw_address = vw_address + vw_elementoffset
|
||||
|
||||
IF INSTR(vw_varType$, "STRING *") > 0 AND (vw_isarray <> 0 OR vw_isUDT <> 0) THEN
|
||||
vw_value$ = LEFT$(vw_value$ + SPACE$(vw_varSize), vw_varSize)
|
||||
ELSEIF INSTR(vw_varType$, "STRING") > 0 THEN
|
||||
IF vw_isarray <> 0 OR vw_isUDT <> 0 THEN
|
||||
'First pass
|
||||
vw_varSize = LEN(vw_dummy%&)
|
||||
vw_buf$ = SPACE$(vw_varSize)
|
||||
vw_m = _MEM(vw_address, vw_varSize)
|
||||
vw_m2 = _MEM(_OFFSET(vw_buf$), vw_varSize)
|
||||
_MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET
|
||||
|
||||
vw_address = _CV(_OFFSET, vw_buf$) 'Pointer to data
|
||||
GOTO setString
|
||||
END IF
|
||||
END IF
|
||||
'--------
|
||||
|
||||
setAddress:
|
||||
'vw_address now points to the actual data
|
||||
|
|
|
@ -8071,7 +8071,6 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
|
|||
END IF
|
||||
|
||||
temp$ = v$
|
||||
_CONSOLE ON: _ECHO "numelements(temp$) =" + STR$(numelements(temp$))
|
||||
IF numelements(temp$) <> 1 THEN
|
||||
'shouldn't ever happen
|
||||
result = idemessagebox("Error", "Only one UDT element can be changed at a time", "#OK")
|
||||
|
@ -8136,7 +8135,6 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
|
|||
END SELECT
|
||||
tempElementOffset$ = MKL$(VAL(MID$(result$, _INSTRREV(result$, sp3) + 1)))
|
||||
END IF
|
||||
_CONSOLE ON: _ECHO "varType$ = " + varType$
|
||||
'-------
|
||||
ELSE
|
||||
_CONTINUE
|
||||
|
@ -8157,14 +8155,9 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
|
|||
END IF
|
||||
LOOP
|
||||
END IF
|
||||
_CONSOLE ON: _ECHO "Will input data"
|
||||
a2$ = ""
|
||||
IF storageSlot& > 0 THEN
|
||||
_CONSOLE ON: _ECHO "Found storage slot"
|
||||
a2$ = vWatchReceivedData$(storageSlot&)
|
||||
_CONSOLE ON: _ECHO "Current data: " + a2$
|
||||
ELSE
|
||||
_CONSOLE ON: _ECHO "Couldn't find storage slot"
|
||||
END IF
|
||||
IF INSTR(varType$, "STRING") THEN
|
||||
thisWidth = idewx - 20
|
||||
|
@ -8190,7 +8183,6 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
|
|||
returnAction = 2 'redraw and carry on
|
||||
END IF
|
||||
selectVar = y
|
||||
_CONSOLE ON: _ECHO "Exiting with returnAction =" + STR$(returnAction)
|
||||
EXIT FUNCTION
|
||||
ELSE
|
||||
result = idemessagebox("Change Value", "Variable is out of scope.", "#OK")
|
||||
|
@ -8731,7 +8723,9 @@ FUNCTION ideelementwatchbox$(currentPath$, elementIndexes$, level, singleElement
|
|||
IF dialogWidth < 40 THEN dialogWidth = 40
|
||||
IF dialogWidth > idewx - 8 THEN dialogWidth = idewx - 8
|
||||
|
||||
idepar p, dialogWidth, dialogHeight, "Add UDT Elements"
|
||||
title$ = "Add UDT Elements"
|
||||
IF singleElementSelection THEN title$ = "Change UDT Element"
|
||||
idepar p, dialogWidth, dialogHeight, title$
|
||||
|
||||
i = i + 1: varListBox = i
|
||||
o(varListBox).typ = 2
|
||||
|
@ -8830,11 +8824,10 @@ FUNCTION ideelementwatchbox$(currentPath$, elementIndexes$, level, singleElement
|
|||
IF singleElementSelection THEN
|
||||
'ok
|
||||
y = ABS(o(varListBox).sel)
|
||||
|
||||
IF y >= 1 AND y <= totalElements THEN
|
||||
IF varDlgList(y).selected = 0 THEN toggleAndReturn = -1: GOSUB toggleWatch: toggleAndReturn = 0
|
||||
END IF
|
||||
toggleAndReturn = -1: GOSUB toggleWatch: toggleAndReturn = 0
|
||||
GOTO buildListToReturn
|
||||
END IF
|
||||
ELSE
|
||||
'add all
|
||||
FOR y = 1 TO totalElements
|
||||
|
@ -8915,7 +8908,16 @@ FUNCTION ideelementwatchbox$(currentPath$, elementIndexes$, level, singleElement
|
|||
|
||||
IF mCLICK AND focus = 1 THEN 'list click
|
||||
IF timeElapsedSince(lastClick!) < .3 AND clickedItem = o(varListBox).sel THEN
|
||||
IF singleElementSelection = 0 THEN
|
||||
GOTO toggleWatch
|
||||
ELSE
|
||||
y = ABS(o(varListBox).sel)
|
||||
IF y >= 1 AND y <= totalElements THEN
|
||||
toggleAndReturn = -1: GOSUB toggleWatch: toggleAndReturn = 0
|
||||
y = ABS(o(varListBox).sel)
|
||||
GOTO buildListToReturn
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
lastClick! = TIMER
|
||||
IF o(varListBox).sel > 0 THEN clickedItem = o(varListBox).sel
|
||||
|
@ -8928,12 +8930,20 @@ FUNCTION ideelementwatchbox$(currentPath$, elementIndexes$, level, singleElement
|
|||
y = ABS(o(varListBox).sel)
|
||||
|
||||
IF y >= 1 AND y <= totalElements THEN
|
||||
IF singleElementSelection THEN
|
||||
varDlgList(y).selected = -1
|
||||
ELSE
|
||||
varDlgList(y).selected = NOT varDlgList(y).selected
|
||||
END IF
|
||||
IF varDlgList(y).selected THEN
|
||||
IF singleElementSelection THEN
|
||||
FOR i = 1 TO totalElements
|
||||
IF i = y THEN _CONTINUE
|
||||
varDlgList(y).selected = 0
|
||||
varDlgList(i).selected = 0
|
||||
ASC(idetxt(o(varListBox).txt), varDlgList(i).colorFlag) = 16
|
||||
ASC(idetxt(o(varListBox).txt), varDlgList(i).colorFlag2) = 2
|
||||
ASC(idetxt(o(varListBox).txt), varDlgList(i).bgColorFlag) = 17
|
||||
ASC(idetxt(o(varListBox).txt), varDlgList(i).indicator) = 32 'space
|
||||
NEXT
|
||||
END IF
|
||||
|
||||
|
@ -8995,6 +9005,7 @@ FUNCTION ideelementwatchbox$(currentPath$, elementIndexes$, level, singleElement
|
|||
thisType = CVL(MID$(elementIndexes$, x * 4 - 3, 4))
|
||||
IF LEN(RTRIM$(udtecname(thisType))) > longestName THEN longestName = LEN(RTRIM$(udtecname(thisType)))
|
||||
varDlgList(x).index = thisType
|
||||
varDlgList(x).selected = 0
|
||||
id.t = udtetype(thisType)
|
||||
id.tsize = udtesize(thisType)
|
||||
|
||||
|
|
Loading…
Reference in a new issue