¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Another IntelliSense script


Eric Selje
 

¿ªÔÆÌåÓý

Here's another IntelliSense script that I hope saves you some time.? I've written about 2 dozen SQL-Insert statements in the last few days before this idea finally hit me.

When you type "sqlins" this script will create a properly formatted INSERT INTO [tablename] (fieldnames*) VALUES (xFieldNames*) from the currently selected alias.? To implement this, go to your IntelliSense manager, go to the Custom tab, and type "fieldlist" into the Replace field (not the quotes).? Select [script] from the drop down menu, and then click on the Script button and paste this in:

LPARAMETER oFoxCode
LOCAL nFields, X, cReturn, cInto, cValues
cInto = ""
cValues = ""
* Create SQL Insert command from all fields
nFields = AFIELDS(aFieldNames)
FOR X = 1 TO nFields
??? cInto = cInto +? IIF(EMPTY(cInto), "", ", ") + LOWER(aFieldNames[X,1])
??? cValues = cValues + IIF(EMPTY(cValues), "", ", ") + LOWER(aFieldNames[X,2]) + PROPER(aFieldNames[X,1])
NEXT
cReturn = [INSERT INTO ] + PROPER(alias()) + " ("+cInto+") ;"+CHR(13)+CHR(9)+"VALUES (~" + cValues + ")"
oFoxCode.valueType = 'V'
RETURN cReturn


Then go back to the Intellisense manager, type sqlins into the Replace field, change the type back to [command], and click Add.? Then click Edit, and put {fieldlist} into the cmd field.? Save it, go out of IntelliSense manager, select a table, and try typing sqlins into either the command window or an editing window.

Enjoy,

Eric

Join [email protected] to automatically receive all group messages.