Home | Reviews | GUIpedia | Forum | Fun500
SonicBrit | Collaborative scripterPerhaps we should collaborate on a scripter together?
I have weird Ideas on how exactly to do a scripter, but heres a run down of what I think needs to be included.
[li]Symbol Name Storage[/li]
[ol][li]Add New[/li]
[li]Lookup Name[/li]
[li]Delete Name[/li][/ol]
[li]Token Parser[/li]
[ol][li]Token Keywords[/li]
[li]Keep track of Loops/If's[/li]
[li]Keep track of Subroutines[/li][/ol]
[li]Internal Routines[/li]
[ol][li]Math Functions[/li]
[li]String Functions[/li]
[li]GUI Functions[/li][/ol]
Whilst I tend to complicate things by doing them my own way, I think we should outline some basic goals.
[ul][li]Simple to Use[/li]
[li]Fast (atleast in basic)[/li]
[li]Easy to understand and modify[/li][/ul] | 2009-09-10 | 7:36 PM |
SonicBrit | Re:Collaborative scripterHeres the source to for the start of a Symbol Name Storage module.
[code]
DECLARE FUNCTION VarAdd% (v$)
DECLARE FUNCTION VarLookup% (v$)
'$DYNAMIC
TYPE PVAR
start AS INTEGER
count AS INTEGER
END TYPE
TYPE VAR
names AS STRING * 32
ptr AS INTEGER
types AS INTEGER
END TYPE
DIM SHARED PVars(1 TO 26, 1 TO 26) AS PVAR
DIM SHARED vars(1 TO 1000) AS VAR
DIM SHARED MaxVars AS INTEGER
PRINT "Should be 0 :"; VarLookup("test1")
PRINT "Should be 1 :"; VarAdd("test1")
PRINT "Should be 2 :"; VarAdd("test2")
PRINT "Should be 1 :"; VarLookup("test1")
PRINT "Should be 2 :"; VarLookup("test2")
REM $STATIC
FUNCTION VarAdd% (v$)
IF LEN(v$) > 26 THEN v$ = MID$(v$, 1, 26)
chk = ASC(UCASE$(v$))
IF chk < 65 OR chk > 90 THEN EXIT FUNCTION
start = PVars(chk - 64, LEN(v$)).start
MaxVars = MaxVars + 1
IF PVars(chk - 64, LEN(v$)).start = 0 THEN
PVars(chk - 64, LEN(v$)).start = MaxVars
ELSE
DO
IF MID$(vars(start).names, 1, LEN(v$)) = v$ THEN
VarAdd% = 0 'VAR ALREADY EXISTS BAD!!!
EXIT FUNCTION
END IF
IF vars(start).ptr = 0 THEN
vars(start).ptr = MaxVars
EXIT DO
END IF
start = vars(start).ptr
LOOP
END IF
vars(MaxVars).names = v$
PVars(chk - 64, LEN(v$)).count = PVars(chk - 64, LEN(v$)).count + 1
VarAdd% = MaxVars
END FUNCTION
FUNCTION VarLookup% (v$)
DIM start AS INTEGER
IF LEN(v$) > 26 THEN v$ = MID$(v$, 1, 26)
chk = ASC(UCASE$(v$))
IF chk < 65 OR chk > 90 THEN EXIT FUNCTION
start = PVars(chk - 64, LEN(v$)).start
WHILE start > 0
IF MID$(vars(start).names, 1, LEN(v$)) = v$ THEN
VarLookup% = start
EXIT FUNCTION
END IF
start = vars(start).ptr
WEND
END FUNCTION
[/code]
PVars are Pointer Vars, it points to the start of a chain of vars given then (first letter of the var, length of the var)
Vars is the Variable storage itself, it contains a name, a type and a pointer to next variable in the chain (If there is one).
VarLookup is used to get the pointer to Vars which could then be used to do more with that particular var.
VarAdd is used to add a new Variable it returns a pointer to Vars which can be used to set values needed.
I could add a VarDelete function which could remove an item from the chain, but at some point the memory will get fragmented if its used too much since only 1000 MaxVars are available. So I would either need to defragment the memory each time delete is called or have a function which can be called later on if all the vars have been used up) | 2009-09-10 | 8:09 PM |
Brandon | Re:Collaborative scripterThis has been talked about in the past, the issue is getting people to contribute/code at all, so it never really worked out. But if you write a decent scripter, I would consider forking or using it for a GUI. | 2009-09-10 | 8:30 PM |
BASIC Programming Help
2021 Brandon Cornell