The Daily Click ::. Projects ::. Expression Editor Plus (E++) ::. Forum
 

Project: Expression Editor Plus (E++)
Project Started: 11th January, 2008 Last Update: 16th September, 2009
Project Owner: DeadmanDines Project Members:
Project Type: Application Project Progress:


 

Public Forum ::. Latest Problem - Variable Loading Again
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
23rd January, 2008

As it scans the code, it looks for strings which match the variables that have already been defined.

I've had to start storing variables in a SQLITE Database rather than List Objects, so that I can sort them by length. But SQLDB Object's only function to make a string legal for SQL (yes, I will name and shame you, 'quote()') is rubbish. So in the middle of a very complex app, I may actually have to make my own.

Can I just point out, it's reasons like this that I've bothered to make E++ in the first place. You look at the objects available to you and think "oh yes, that'll be easy to sort", try using them, but lo! There's a bug! And another! And another!

And you end up having 50 lines of code for the program and 50 for the workarounds. Which are hard to do because, thankyou Clickteam, you still never gave us some decent custom function support.

So my best bet is to try Blowfish, see if I can use the Filter function to manually SQL-Friendlify all my variables, whilst being processed in an ever-more cumbersome nested loop.

Additionally, it can't currently tell what bit of code is defining a variable name, and what bit defines the variable's data.

So if I do this:

//Some code
name = "blah";
fullname = "yada";

it becomes:

//Some code
name = "blah";
full"blah" = "yada";

...because it saw 'name' in 'fullname' and inserted it there.

So that sucked. In an attempt to fix it, I added a flag to trip on/off when an = or ; is found. So it starts OFF, hits an = to turn ON, then hits a ; to turn OFF again. That prevents a variable being inserted in the naming part of a statement.

...But of course, I'd not be ranting if it were that easy! Hoh no! So we get to the final statement, which obviously has no variable assigned, because it's our final return statement. Like this:

//Wee!
my variable = "Wee!";

//Final output:
my variable + "This is my final output"

...that leaves us with... no changes at all! Because it's seen no = sign, therefore that whole final statement appears to be a naming structure.

So I gotta do an additional test, to switch off the flag when it reaches a semicolon, BUT ONLY if the next statement contains an = and a semicolon. And if it does, these must be located outside of any comment blocks or strings (just in case some spacker wants to print a string like "This is = messing up; someone's app" which would cause the whole elaborate plan to die horribly). That's all well and good, except the only way to find this out, is to continue seeking through the file, passing any possible variables. By the time we get to the end and see 'oh yes, so it was the final statement after all', we have to return to the start of the statement and reprocess it, this time substituting variable names for their full equivalents.


Unsurprisingly, it's a small workaround I haven't quite coded yet...


....AAAAAAAAAAAAARRRRRRRRRRRGGGGGGGGHHHHHHHHHHHH!!!!!!!!!

 
191 / 9999 * 7 + 191 * 7

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
24th January, 2008

Update

Strangely enough, these weren't too tough to fix. It generated its first working Quadratic Bézier Curve formula today.

 
191 / 9999 * 7 + 191 * 7

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
31st January, 2008

A new error developed: It doesn't like variables whose data is just 1 digit long. Eg:

my var = 1;

Also, it currently treats function names as variables. Eg:

Text = "blah";


GetText$( text )


becomes:

Get"blah"$( "blah" )

that's gonna be tricky to sort. Would be easy, but it has to handle whitespace between function name and brackets. I may just make whitespace between a function and its bracket illegal.

 
191 / 9999 * 7 + 191 * 7

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
18th February, 2008

Ok, for my own notes (to help me work this out):

Variables pasting into function names

To insert a variable, the area just right of it must meet these conditions:

IS one of %^&|~/*+-; or end of script
NOT an open bracket (
NOT a $

However, there may be whitespace between, meaning it can't just check the space immediately right of the potential variable.

Suggested Solution: Add the following values in MMF:

tmp var insert point = the location where the variable will be inserted. Defaults to -1.
tmp var to insert = string. The variable name to insert. Defaults to blank.

When a variable is found with whitespace next to it, these values are filled in. No variable is inserted, and processing continues. However, a small process is kept alive to check for the above conditions. When it hits a $, (, or one of the other characters, it either inserts the variable where it was supposed to go, or ignores it and carries on.

EDIT 18 Feb 08: Fixed, though not in this way.


1-char Vardata

Must investigate why this occurs.
EDIT 18 Feb 08: Fixed. Caused by an error with 'delete element' in String Parser. Resolved by replacing the 'delete' command with a 'set element to' command, and then changing the element to an empty string.

 
191 / 9999 * 7 + 191 * 7
   


 



Project Forums


Advertisement

Worth A Click