-
May 9th, 2012, 11:02 AM
#1
Thread Starter
Member
Script Engine - VB.NET Based
I recently came to the experience that there are a few real good script engines done VB.NET so i made up my mind and started to code my own engine wich had all the features i liked most seen from the VSA class method or the old MSScript.
With all that in mind, maybe some of you seen the script engine of mIRC and i really like its simplicity and how high its tolerance level was on performing tasks.
So far im done with the following:
- Basic parser (Such as if-else-end or while-loops)
- Evaluating variables and identifiers
- Custom events
- Object binding (Expose you components to the engine)
- Custom DLL loading (Use external dll functions for tasks like the plugin idea)
editted, making changes.
At this point the engine does what i want on a few things i want to make more complex like local variables , now i have a global variable system and
a better if-then parser , this one does the job but cannot handle a second if-statement while being in one.
Maybe you guys have suggestion for me.
Sincerly Barret,
Last edited by TheBarret; May 10th, 2012 at 10:07 AM.
-
May 9th, 2012, 01:10 PM
#2
Re: Script Engine - F2
Hello Barret and welcome to the VBForums.
Before I comment on your scripting language I need to inform you about the rules of this forum:
This is not a place for show casing your work but if you have a specific question you are more than welcome to post here. Since the only question you have are more in the form of "what do you think?" I'm going to move this thread to the chit-chat forum.
Over to your post:
Over the years I've created several vertical languages and I've also created one full fledged language with its own IDE. So I'm very interested in giving you a hand with anything you want to achieve with this.
With that said, I must say that I find the structure of your language a bit odd. For example you use -> for both assignment and as the object inspector (the separator between the object and its properties). I also find your WHILE loop confusing, but I suspect that is because of a typo in your code... To me the following: "while (%i == 10)" would mean that you would never enter the while loop since the variable %i has the value 1 when it reach that line. Or doesn't the while statement read "while %i is equal to 10"?
-
May 9th, 2012, 01:14 PM
#3
Re: Script Engine - F2
Isnt this something more suitable to the code bank than chit chat ?
Also, why not simply model your language on C's syntax ? Its easily the most popular syntax for scripting languages.
-
May 9th, 2012, 01:35 PM
#4
Thread Starter
Member
Re: Script Engine - F2
Originally Posted by Joacim Andersson
With that said, I must say that I find the structure of your language a bit odd. For example you use -> for both assignment and as the object inspector (the separator between the object and its properties). I also find your WHILE loop confusing, but I suspect that is because of a typo in your code... To me the following: "while (%i == 10)" would mean that you would never enter the while loop since the variable %i has the value 1 when it reach that line. Or doesn't the while statement read "while %i is equal to 10"?
Your totally right (on that while loop), i made huge mistake there ill make the changes right away.
maybe i was sleepy atm i was doing it, so much lines of code
The "->" are indeed looking out of place but they are handled by the function trap, first it checks if the object is actually binded, then it goes to the next param wich is the property, then it checks if the property does exist in there, then it checks what kind of type the value holds of that property, (bool,string, etc) and converts to a proper value to finally set the value given.
- Barret
-
May 9th, 2012, 01:41 PM
#5
Re: Script Engine - F2
Originally Posted by Niya
Isnt this something more suitable to the code bank than chit chat ?
The Code Bank is for sharing source code so it doesn't fit there either. It either belongs here or not at all in these forums.
-
May 9th, 2012, 01:51 PM
#6
Re: Script Engine - F2
Originally Posted by TheBarret
The "->" are indeed looking out of place but they are handled by the function trap, first it checks if the object is actually binded, then it goes to the next param wich is the property, then it checks if the property does exist in there, then it checks what kind of type the value holds of that property, (bool,string, etc) and converts to a proper value to finally set the value given.
I understand how you handle it. What I meant was that the structure itself is wrong. You don't use -> to assign values to variables so why would you use it to assign values to properties?
Code:
%i->1 INCORRECT syntax
%i=1 CORRECT syntax
The -> arrow seams to be pointing in the wrong direction. It would make more sense if it was:
Code:
textbox->enabled<-false
How do you handle properties that are by themself objects?
Code:
textbox->font->size->12
or if I want to assign the font size to a variable, according to your code it would be
Code:
%i=textbox->font->size
So now you suddenly use the equal sign for assignment but to do the opposite you do:
Code:
textbox->font->size->%i
If I would use your script language I would find this very confusing.
Last edited by Joacim Andersson; May 9th, 2012 at 01:55 PM.
-
May 9th, 2012, 02:26 PM
#7
Thread Starter
Member
Re: Script Engine - F2
Good points sir, ill change this asap. huge thanks for this feedback!!!
I cannot "rep" you for this feedback if i could then i would.
Last edited by TheBarret; May 9th, 2012 at 02:30 PM.
-
May 9th, 2012, 02:51 PM
#8
Re: Script Engine - F2
No you can't give reputation points in the Chit-Chat forum but you need to have 10 posts before your rep points counts anyway and posts in Chit-Chat doesn't increase your post count either.
-
May 9th, 2012, 02:53 PM
#9
Thread Starter
Member
Re: Script Engine - F2
Oh well then i shall use the power of words
Thank you very much for your time
-
May 9th, 2012, 03:14 PM
#10
Thread Starter
Member
Re: Script Engine - F2
Ok re-coded that part of where the engine starts reconizing the "object" functions
Code:
function start
!form.text = Hello there!
end function
function button_click1
//Disable component
!textbox.enabled = false
!textbox.visible = false
end function
function button_click2
//Enable component
!textbox.enabled = true
!textbox.visible = true
end function
-
May 9th, 2012, 03:26 PM
#11
Re: Script Engine - F2
Why the exclamtion point? Is exclamation used for objects and % for variables or do you have more of these and if not why make a distinction between what would be a reference variable (the textbox object) and a value variable? In your earlier post you showed code (before you edited it) that used == for equality comparison my question is: What do you use for "not equal"? I hope you don't plan to use the exclamation point for the NOT operator because then the above would be very confusing. (since it would be read as: NOT textbox.enabled = false).
Last edited by Joacim Andersson; May 9th, 2012 at 03:29 PM.
-
May 9th, 2012, 04:02 PM
#12
Thread Starter
Member
Re: Script Engine - F2
Originally Posted by Joacim Andersson
Why the exclamtion point? Is exclamation used for objects and % for variables or do you have more of these and if not why make a distinction between what would be a reference variable (the textbox object) and a value variable? In your earlier post you showed code (before you edited it) that used == for equality comparison my question is: What do you use for "not equal"? I hope you don't plan to use the exclamation point for the NOT operator because then the above would be very confusing. (since it would be read as: NOT textbox.enabled = false).
Its because the engine parses into commands if not found it evaluates the line, the "!" is a mark that the line is part of object.
What is your suggestion for "equal" and "not equal" sign then?
-
May 9th, 2012, 04:45 PM
#13
Re: Script Engine - F2
What I'm saying is that if you use the exclamation point as a marker it should not also be used as an operator which would rule out != for "not equal" and also rule out ! for NOT. So if you can't use != for not equal I guess the only other choice would be <>.
-
May 9th, 2012, 04:55 PM
#14
Thread Starter
Member
Re: Script Engine - F2
Originally Posted by Joacim Andersson
What I'm saying is that if you use the exclamation point as a marker it should not also be used as an operator which would rule out != for "not equal" and also rule out ! for NOT. So if you can't use != for not equal I guess the only other choice would be <>.
Indeed, never approached it from that view. Well i tried to keep some other script engines as "reference" how they do it but i also want to give it a little bit of my own ways, but did not figure out that it might be easy to read for me but for someone else totally crappy or not understand a single line.
Thank you Joacim, you help me see the things they make sense.
Last edited by TheBarret; May 9th, 2012 at 04:59 PM.
-
May 9th, 2012, 09:30 PM
#15
Re: Script Engine - F2
Moved from Chit Chat.
Interesting thread.
-
May 10th, 2012, 10:03 AM
#16
Thread Starter
Member
Re: Script Engine - F2
Ok i changed alote of things arround, had some trouble with the "seperator" wich is my engine the "," (comma) so what i did was before a identifier is being checked or set to a variable it will check and will replace wit a temp. symbol that later will be put back again.
Procedure i take when i parse:
- New function call
- Checks if function does exist
- "script" input comes in as a array variable
- Checks params and store it in the variable table
- Enters a for-loop (to do per line)
- Trims spaces from the begin and end of the line and removes vbtabs
- Splits the line using the space as delimeter so we get: <CMD> <identifiers>
- Enters a select-case that checks the <CMD>
-- if case <cmd>:
- Filters out the variables and returns when found any
- Evaluate ($) identifiers, this will then parse per-character and determines what identifiers are used (supports embedded identifiers) and replace the return values of these identfiers
- Performs the command (and return value if any)
-- if Case else:
- if the line starts with $ , evaluate the line but might not return any value (like $sleep(1000) )
- if the line starts with _ , tells the engine its an object, give input to other function that handles it
- if the line starts with % is an variable , new/update that variable with given value
- if all not pass, then it might be a function within the script itself, try's to call it with params and return
- if else: unkown cmd
- Before it exits the for-loop it checks if where not currently in a do/while/if conditions
Others things i took in account:
- Script side variables are being checked what kind of type value it is (integer,boolean,string) and converts it
- Strip for illegal chrs and seperators
- Object handling also checks what kind of value the property accepts and will convert if possible
(This is still experimental because it does not support if the property only accepts a new object)
- I have a list of consts that define all the syntaxes and such so i can change certain things quit easily.
This might be look silly to you but this is my first time making a script parser so do be to hard on me :P
Overall, the engines runs pretty good i implemented a stopwatch that calculates the execution time and big scripts never exceed the 1000+ms
- Barret
-
May 10th, 2012, 11:22 AM
#17
Re: Script Engine - VB.NET Based
How are you handling assignments?
Code:
%s = _textbox.text
Or when there are no spaces?
-
May 10th, 2012, 11:47 AM
#18
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by Joacim Andersson
How are you handling assignments?
Code:
%s = _textbox.text
Or when there are no spaces?
Little change of format all function/params are inside of brackets {} instead of () this is because i had a problem with the $calc{} that also accepts () so i had to approach it from this way.
To your qeustion:
I have a ($) identifier for that, lets say i have declared a name "form" that represents my current app form
then i would get it's property like this:
Code:
function GetAppTitle
%title = $object{form,text}
echo My app title is: %title
end function
The format of " = " is before handling replaced with the correct format, with the exception to replace just on 1 occourence so that it will not filter the rest out if that holds a "=" as well.
Code part wich is responsible for that:
Code:
If (Left(Line, 1) = F2Tables.C_VARIABLE) Then
' Here is that part, looks for a wrong format
If (InStr(Line, F2Tables.C_VARIABLE_SET_DELIM_WRONG, CompareMethod.Text) > 0) Then
'Replace it but just once so it wont reformat the value
Line = Replace(Line, F2Tables.C_VARIABLE_SET_DELIM_WRONG, F2Tables.C_VARIABLE_SET_DELIM, 1, 1)
End If
If (InStr(Line, F2Tables.C_VARIABLE_SET_DELIM) > 0) Then
Dim p() As String = Split(Line, F2Tables.C_VARIABLE_SET_DELIM, 2)
If (p.Length < 1) Then GoTo NextLine
Dim cVar As String = p(0) : Dim cVal As String = p(1)
cVal = EvalVars(cVal) : cVal = IdentifierParser.Parser(cVal, Me) : Variables.UpdateVar(cVar, cVal)
GoTo NextLine
End If
End If
Example script:
Code:
function start
%title=$object{form,text}=some text with = = == = = =
echo %title
end function
This will output exactly what i want and will leave the other '=' occourences alone.
It works but im sure it could be done in a different way i guess.
- Barret
Last edited by TheBarret; May 10th, 2012 at 12:12 PM.
-
May 10th, 2012, 12:49 PM
#19
Re: Script Engine - VB.NET Based
So you can't check if one value is equal to another and assign the boolean result to a variable?
Code:
' assign true if %a is equal to %b
%c = %a == %b
-
May 10th, 2012, 12:57 PM
#20
Re: Script Engine - VB.NET Based
alternative - make the assignment token := rather than a simple =
' assign true if %a is equal to %b
%c := %a = %b
-tg
-
May 10th, 2012, 01:50 PM
#21
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by Joacim Andersson
So you can't check if one value is equal to another and assign the boolean result to a variable?
Code:
' assign true if %a is equal to %b
%c = %a == %b
I'm afraid that part hasn't been come to my attention but i'll come to that later with and with such good help within this forum community
Anyway i did some testing with do-loops and reading from INI file.
example script:
Code:
function start
%file = $startpath{}\test.ini
%x = 1
do (%x==$ini{%file,-1})
echo Key: $iniread{%file,$ini{%file,%x},key%x}
%x++
enddo
end function
The INI file :
Code:
[test1]
key1=This
[test2]
key2=INI reader
[test3]
key3=Works!
Results in:
Code:
Key: This
Key: INI reader
Key: Works!
My goal was to test out if my engine could perform embedded identifiers with do-loops and read them out correctly to the functions.
The ini function are simple,
$ini(file,-1) = Total topics in the ini
$ini(file,x) = returns the name x'th topic in the ini (and so on...)
$iniread(file,topic,key)
Suggestions are welcome!
- TB
-
May 10th, 2012, 02:15 PM
#22
Re: Script Engine - VB.NET Based
I find it a bit confusing that you don't quote literal strings.
Would is the output of this?
-
May 10th, 2012, 02:17 PM
#23
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by Joacim Andersson
I find it a bit confusing that you don't quote literal strings.
Would is the output of this?
That will come out the same "1+2" for math i have a identifier $calc{1+2}
-
May 10th, 2012, 02:27 PM
#24
Re: Script Engine - VB.NET Based
Can you escape the dollar sign? Let's say I wanted this output: "The result of $calc{1+2} is 3". This code wouldn't work for that:
Code:
echo The result of $calc{1+2} is $calc{1+2}
since that would output "The result of 3 is 3".
-
May 10th, 2012, 02:32 PM
#25
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by Joacim Andersson
Can you escape the dollar sign? Let's say I wanted this output: "The result of $calc{1+2} is 3". This code wouldn't work for that:
Code:
echo The result of $calc{1+2} is $calc{1+2}
since that would output "The result of 3 is 3".
Good point, i think i can code something easy for that, ill modify the char-parser to detect " as escape and continue when another one is found.
-
May 10th, 2012, 03:25 PM
#26
Thread Starter
Member
Re: Script Engine - VB.NET Based
I regret saying "easy" because this was tricky!!
To let the engine recognize an escape (quote) char was easy, but the code that replaces that specific part of a line was hard (if you got identically parts)!
Here's what i did:
I made a new function that rebuilds a given string but will skip characters from x to y. Now once that is done, i used the String.insert(x) to insert that evaluated value back in. This function is usefull if the strLine has parts with are identical to eachother.
Code:
Public Function RebuildString(StrLine As String, ReplaceWith As String, SkipFrom As Integer, SkipStop As Integer) As String
Dim TmpLine As String = ""
For i = 1 To Len(StrLine)
If (i < SkipFrom) Or (i > SkipStop) Then
TmpLine = TmpLine & Mid(StrLine, i, 1)
End If
Next
TmpLine = TmpLine.Insert(SkipFrom - 1, ReplaceWith)
Return TmpLine
End Function
I could use the Replace() but somehow it did not what i wanted so i made this function just for this purpose.
Script example:
Code:
function start
echo "$calc{1+2}" $calc{1+2} "$calc{1+2}" $calc{1+2}
end function
Notice the quote's, now i want just the non-quoted parts to be evaluated and the rest to be just how they are.
This will output:
Code:
"$calc{1+2}" 3 "$calc{1+2}" 3
- TB
Last edited by TheBarret; May 10th, 2012 at 03:30 PM.
-
May 10th, 2012, 03:31 PM
#27
Re: Script Engine - VB.NET Based
It almost looks like you're writing this with VB6. Here's the same function in a more VB.Net way:
Code:
Public Function RebuildString(line As String, replaceWith As String, skipFrom As Integer, skipStop As Integer) As String
Return line.SubString(0, skipFrom) & replaceWith & line.SubString(skipStop, line.Length - skipStop)
End Function
-
May 10th, 2012, 03:43 PM
#28
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by Joacim Andersson
It almost looks like you're writing this with VB6. Here's the same function in a more VB.Net way:
Code:
Public Function RebuildString(line As String, replaceWith As String, skipFrom As Integer, skipStop As Integer) As String
Return line.SubString(0, skipFrom) & replaceWith & line.SubString(skipStop, line.Length - skipStop)
End Function
I know .NET has alote of functions i have yet to discover, im glad you show me this one, i feel kinda stupid now
-
May 10th, 2012, 04:54 PM
#29
Re: Script Engine - VB.NET Based
Originally Posted by TheBarret
Script example:
Code:
function start
echo "$calc{1+2}" $calc{1+2} "$calc{1+2}" $calc{1+2}
end function
Notice the quote's, now i want just the non-quoted parts to be evaluated and the rest to be just how they are.
This will output:
Code:
"$calc{1+2}" 3 "$calc{1+2}" 3
So the output will include the quotes?
-
May 10th, 2012, 05:19 PM
#30
Thread Starter
Member
Re: Script Engine - VB.NET Based
I just finished that part, the awnser is no, they are removed upon return from where it was called.
Had to make sure every other function still works the same since i changed the char-parser a bit.
-
May 10th, 2012, 07:15 PM
#31
Re: Script Engine - VB.NET Based
Can you put quote characters within quotes?
-
May 10th, 2012, 07:41 PM
#32
Thread Starter
Member
Re: Script Engine - VB.NET Based
Originally Posted by penagate
Can you put quote characters within quotes?
Actually i did a test, for a moment i was not sure until i thought why not "cheat" my own engine so to call. What my engine does if it finds symbols that are in this case " (quote's) removed up detection because they set out a param or non-evaluating area's it replaces them for so called shortcuts.
like, a quote is \\^34 and a comma \\^44 and so on...
Heres what it looks like:
Code:
function start
echo "This is a \\^34 within a quoted line"
end function
Output: This is a " within a quoted line
So your awnser is yes, thats possible but it only applies to those kind of symbols that the engine filters out, perhaps i could add the whole ascii table in there just to make it another functional possibility.
I used ascii table to keep the right number for that character (http://www.asciitable.com/index/asciifull.gif)
- TB
Last edited by TheBarret; May 10th, 2012 at 07:55 PM.
-
May 11th, 2012, 08:11 AM
#33
Thread Starter
Member
Re: Script Engine - VB.NET Based
I just started to rethink of the $calc{} and realized that this function has alote of important functions within scripts so i was in doubt if i would re-invent the wheel or not, i decide to use a library that takes care of this evaluation of this function.
So i picked nCalc for this wich is very powerfull.
Link: http://ncalc.codeplex.com/
Or is there a better solution to this?
-
May 12th, 2012, 03:23 PM
#34
Thread Starter
Member
Re: Script Engine - VB.NET Based
Redid the variable_check code, altho im not sure if im doing it right. however it does work.
Maybe any suggestions on this code:
Code:
Private Function ReplaceVars(Evalstr As String) As String
Dim CurrentChar As String = ""
Dim TheName As String = ""
Dim Value As String = ""
Dim InVar As Boolean = False
Dim LastPos As Integer = 0
Again:
For x = 1 To Len(Evalstr)
CurrentChar = Mid(Evalstr, x, 1)
'* We hit a var syntax, start collecting
If (CurrentChar = F2Tables.C_VARIABLE) Then LastPos = x : InVar = True
'* Stop collecting once we hit:
' - Brackets {}
' - Brackets2 ()
' - Operators +-*/
' - Identifier syntax $
' - or a space
If (CurrentChar = " ") Then InVar = False
If (CurrentChar = F2Tables.C_SYNTAX) Then InVar = False
If (CurrentChar = F2Tables.C_BRACKET_START) Then InVar = False
If (CurrentChar = F2Tables.C_BRACKET_END) Then InVar = False
If (CurrentChar = F2Tables.C_BRACKET2_START) Then InVar = False
If (CurrentChar = F2Tables.C_BRACKET2_END) Then InVar = False
If (CurrentChar = F2Tables.C_OP_ADD) Then InVar = False
If (CurrentChar = F2Tables.C_OP_SUB) Then InVar = False
If (CurrentChar = F2Tables.C_OP_MULT) Then InVar = False
If (CurrentChar = F2Tables.C_OP_DIV) Then InVar = False
'Collect bool is true, start collecting...
If (InVar = True) Then
TheName = TheName & CurrentChar
'This was all, then put the collect bool back to false
If (x = Len(Evalstr)) Then InVar = False
End If
'if collect bool is false and we have still a name
'in the collect var, lets see if that returns a value
If (InVar = False) And (Len(TheName) > 0) Then
Value = Variables.GetVar(TheName)
If (Len(Value) > 0) Then
Evalstr = RebuildString(Evalstr, Value, LastPos, (LastPos + (Len(TheName) - 1)))
TheName = ""
Value = ""
InVar = False
LastPos = 0
'Eval string has changed that means we need to do the for-loop again.
GoTo again
End If
'To make sure...
TheName = ""
End If
Next
Return Evalstr
End Function
You might wonder why i use this method simply because to avoid the problem that occours when you have
two variables that are like: %x and %xx
If you use the Replace() function that will change all the %x in the current line so i had to do it per-char.
Thank you in advance!
- TB
Last edited by TheBarret; May 12th, 2012 at 03:28 PM.
-
May 12th, 2012, 07:09 PM
#35
Re: Script Engine - VB.NET Based
Sorry, I stopped reading as soon as I saw that you had a label, named Again, which made me convinced that there's a (oh horror) Goto statement somewhere in there.
-
May 13th, 2012, 03:46 AM
#36
Thread Starter
Member
Re: Script Engine - VB.NET Based
Well im sorrie that im not an expert on coding, maybe you can give me a suggestion how to improve myself how to avoid using these methods. not asking to code for me but little direction would help.
-
May 13th, 2012, 06:28 AM
#37
Re: Script Engine - VB.NET Based
You could use a Do ... Loop While instead of a Goto. Your many If statements could be a single Select Case statement.
Code:
Select Case CurrentChar
Case " ", F2Tables.C_SYNTAX, F2Tables.C_BRACKET_START, F2Tables.C_BRACKET_END, _
F2Tables.C_BRACKET2_START, F2Tables.C_BRACKET2_END, F2Tables.C_OP_ADD, _
F2Tables.C_OP_SUB, F2Tables.C_OP_MULT, F2Tables.C_OP_DIV
InVar = False
End Select
-
May 13th, 2012, 04:09 PM
#38
Thread Starter
Member
Re: Script Engine - VB.NET Based
Been reading on why GoTo's are bad and now i understand but also find it pretty confusing on the reactions people give. Seems half of them say it's ok but not too much the other half just treats you like a retard when they see you do it. There are i guess rare situation where you cannot use any other method then "GoTo" but im gonna make a long story short, "Use goto only as a last resort". no harm in that.
Ontopic:
I used in my entire project just 1 goto and i applied the rule i just typed.
And correct me if im wrong, since you are mod the reaction you gave me was not of better taste either.
-TB
-
May 13th, 2012, 04:35 PM
#39
Re: Script Engine - VB.NET Based
If you can show me one single time where a Goto is needed then I'll show you how you have used bad structure in your code.
Maybe this can convice you of what can happen when you use Goto statements:
http://xkcd.com/292/
I'm sorry if I didn't read your code because you used a goto but my head hurts when I read unstructured code but then I showed you a better way of doing it. I'm sorry if my comment hurt your feeling, it was not my intention to come out as rude.
Last edited by Joacim Andersson; May 13th, 2012 at 04:48 PM.
-
May 14th, 2012, 04:06 PM
#40
Thread Starter
Member
Re: Script Engine - VB.NET Based
Was not about hurting feelings more about manors.
Anyway, ive been doing new ways of this current function but i cannot see any other solution.
What happens is, the function loops trough the string that searches the variables once found it will replace the variable name with the value but this will change the orginal line that it was looping trough, so i thought well lets save it to a temp string but then the rebuildstring function does not work since the length of the orginal and new line do not match anymore wich is needed in order to get the position of the variable name and replacement.
I cannot see how this could be done differently...
Code:
Private Function CheckForVar(strline As String) As String
Dim TmpLine As String = strline
Dim CurrentChar As String = ""
Dim VarName As String = ""
Dim VarValue As String = ""
Dim Pos As Integer = 0
Dim PosT As Integer = Len(strline)
Dim Check As Boolean = False
Again:
For i = 1 To PosT
CurrentChar = Mid(TmpLine, i, 1)
If (CurrentChar = TABLE_VARIABLE_SYNTAX) Then
If (Check = False) Then
Check = True
Pos = i
Else
RaiseError("Unexpected variable symbol")
Return ""
Exit Function
End If
End If
If (Check = True) Then
If (CurrentChar = " ") Then
VarName = Replace(VarName, TABLE_VARIABLE_SYNTAX, "")
VarValue = Variables.GetVar(VarName)
TmpLine = RebuildString(TmpLine, VarValue, Pos, Pos + Len(VarName))
Check = False
VarName = ""
VarValue = ""
GoTo Again
End If
If (i = PosT) Then
VarName = Replace(VarName, TABLE_VARIABLE_SYNTAX, "")
VarValue = Variables.GetVar(VarName)
TmpLine = RebuildString(TmpLine, VarValue, Pos, Pos + Len(VarName))
Check = False
VarName = ""
End If
End If
If (Check = True) Then
VarName = VarName & CurrentChar
End If
Next
Return TmpLine
End Function
Little help is needed i suppose.
-TB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|