PDA

View Full Version : Questions about SDK-functions (Syntax, Parameters etc.)



ReneMiner
22-01-2021, 20:28
my question of today is about thinBasic_GetKeywordSpeficic

All i know is


'----------------------------------------------------------------------------
'thinBasic_GetKeywordSpeficic
'----------------------------------------------------------------------------
' Instruct parser to get next token, test if it a keyword and if yes,
' check if it is one of the possible keywords passed. If not, a RT-Error
' will be generated
'----------------------------------------------------------------------------
DECLARE FUNCTION thinBasic_GetKeywordSpeficic _
LIB "thinCore.DLL" _
ALIAS "thinBasic_GetKeywordSpeficic" _
( _
BYVAL HideError AS LONG , _
BYVAL AutoPutBack AS LONG , _
BYVAL lKey1 AS LONG , _
OPTIONAL BYVAL lKey2 AS LONG , _
BYVAL lKey3 AS LONG , _
BYVAL lKey4 AS LONG , _
BYVAL lKey5 AS LONG , _
BYVAL lKey6 AS LONG , _
BYVAL lKey7 AS LONG , _
BYVAL lKey8 AS LONG , _
BYVAL lKey9 AS LONG , _
BYVAL lKey10 AS LONG , _
BYVAL lKey11 AS LONG , _
BYVAL lKey12 AS LONG , _
BYVAL lKey13 AS LONG , _
BYVAL lKey14 AS LONG , _
BYVAL lKey15 AS LONG , _
BYVAL lKey16 AS LONG , _
BYVAL lKey17 AS LONG , _
BYVAL lKey18 AS LONG , _
BYVAL lKey19 AS LONG , _
ByVal lKey20 As Long , _
ByVal lKey21 As Long , _
ByVal lKey22 As Long , _
ByVal lKey23 As Long , _
ByVal lKey24 As Long , _
ByVal lKey25 As Long _
) As Long




i guess i have to store up to 25 different keywords to lKey1 to lKey25 ?
What is the rule? why "As Long? Will it return the number 1 to 25 telling me the keyword? isn't it possible without to create an Error?

ReneMiner
25-01-2021, 22:43
rIs there no other way than to create a list of thinBasic-keywords and scan it for existance of a string-expression to make sure a name for a new variable or a new udt is not used yet?
i mean its quite a big list and thinCore probably has built-in some function already to check if a string matches any keyword or other, name or identifier. especially if my module will have to check multiple times for user-defined names if anything matches to keywords user dimensioned names as class-names, udt-names, variable-names, controls-names.

A new function App_ListNames could be developed for runtime-usage from within a thinbasic script. But as already mentioned, from a module i will have to perform these tests multiple times. if other developers modules have to validate names too and all would keep theie lists of Keywords, Functions, user-defined names etc. to maintain in memory then available memory will shrink fast towards zero.

Since multiple modules might be in use it makes no sense to maintain such lists because we don't know if nor how many additional names were added by other developers. Means to let thinbasic collect all data about keywords etc. again and compare if the name by the user suggested is still available - or not.

Also the question if a user desired string-expression matches the naming-conventions of thinBasic has to be asked over and over again by all modules that will add udts, variables, equates, controls and even functions. i think thincore is the first who knows if anything with a new name was added or if a previously collected list of variables, udts etc.is still valid

I would suggest to develop 2 functions for the sdk,
### 1###
the first function to test if a name can be used for a certain purpose and follows the rules like start with a letter or be prefixed with $ or % for equates and consist of word chars only and functions or variables for numerals must not end with $

(Extended rules including enforcement of naming rules are thinkeable as a preparsing directive to reduce errors caused by typos or confusion, i.e. not on purpose exchanged names. Ass a class variable has to be prefixed with c or cls , use underscore or have suffix "_class" could be made an optional ruleset as



#Default Name {(Prefix|Suffix) Len(1|3|full) } [,Using Underscore]

)

### 2 ###
the second function would allow to check if the string containig the desired new name is available or in use by something else already.

can it be that those 2 functions become a "sdk-module" to be used by any module or are already functions present for this purpose?