#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" MySQL3 on doLog pData put pData & cr after fld "Data" set the scroll of fld "Data" to 30000 end doLog on makeConnection put the dbConnectName of this stack into dbName put the dbConnectAddr of this stack into dbHost put the dbConnectUser of this stack into dbUser put the dbConnectPass of this stack into dbPass get revOpenDatabase("MySQL",dbHost,dbName,dbUser,dbPass) if it is a number then set the dbConnectID of this stack to it doLog "Connected to " & dbName & ", ID = " & it set the label of btn "Connect" to "Disconnect" else set the dbConnect of this stack to empty answer it end if end makeConnection on closeConnections set the dbConnectID of this stack to empty put revOpenDatabases() into dbList repeat for each item d in dbList revCloseDatabase d doLog "Disconnected from ID = " & d end repeat end closeConnections on showCursor curID put "-" into tDiv put revDatabaseColumnCount(curID) into colNum repeat colNum times put "--------------|" after tDiv end repeat put revDatabaseColumnNames(curID) into colNames replace comma with tab & "|" in colNames put tDiv & cr & colNames & tab & "|" & cr & tDiv & cr into curDisplay put revNumberOfRecords(curID) into recNum if recNum > 0 then repeat repeat with c = 1 to colNum put revDatabaseColumnNumbered(curID, c) into temp if temp is empty then put "NULL" into temp put temp & tab & "|" after curDisplay end repeat put cr after curDisplay revMoveToNextRecord curID if the result = false then exit repeat end repeat end if put tDiv after curDisplay revCloseCursor curID doLog curDisplay end showCursor function formatSQL pQuery put the mySQLreservedWords of this stack into tWords put empty into newQuery replace cr with space in pQuery if last char of pQuery = ";" then delete last char of pQuery repeat for each word W in pQuery if tWords contains W then put toUpper(W) & space after newQuery else put W & space after newQuery end if end repeat delete last char of newQuery if word 1 of newQuery is in "SELECT,DESCRIBE,SHOW" then put ";" after newQuery return newQuery end formatSQL on executeSQL put formatSQL(fld "Query") into fld "Query" put fld "Query" into dbSQL doLog "> " & dbSQL revExecuteSQL the dbConnectID of this stack, dbSQL if the result is a number then doLog "Query OK: " & the result & " record(s) altered." else doLog the result end if end executeSQL on querySQL put formatSQL(fld "Query") into fld "Query" put fld "Query" into dbSQL doLog "> " & dbSQL put revQueryDatabase(the dbConnectID of this stack, dbSQL) into curID if curID is a number then showCursor curID else doLog curID end if end querySQL @e& dbConnectdbConnectNamedbConnectAddrMySQLreservedWordsADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE AUTO_INCREMENT BDB BEFORE BERKELEYDB BETWEEN BIGINT BINARY BLOB BOTH BTREE BY CALL CASCADE CASE CHANGE CHAR CHARACTER CHECK COLLATE COLUMN COLUMNS CONNECTION CONSTRAINT CREATE CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURSOR DATABASE DATABASES DAY_HOUR DAY_MINUTE DAY_SECOND DEC DECIMAL DECLARE DEFAULT DELAYED DELETE DESC DESCRIBE DISTINCT DISTINCTROW DIV DOUBLE DROP ELSE ELSEIF ENCLOSED ERRORS ESCAPED EXISTS EXPLAIN FALSE FIELDS FLOAT FOR FORCE FOREIGN FROM FULLTEXT GRANT GROUP HASH HAVING HIGH_PRIORITY HOUR_MINUTE HOUR_SECOND IF IGNORE IN INDEX INFILE INNER INNODB INOUT INSENSITIVE INSERT INT INTEGER INTERVAL INTO IS ITERATE JOIN KEY KEYS KILL LEADING LEAVE LEFT LIKE LIMIT LINES LOAD LOCALTIME LOCALTIMESTAMP LOCK LONG LONGBLOB LONGTEXT LOOP LOW_PRIORITY MASTER_SERVER_ID MATCH MEDIUMBLOB MEDIUMINT MEDIUMTEXT MIDDLEINT MINUTE_SECOND MOD MRG_MYISAM NATURAL NOT NULL NUMERIC ON OPTIMIZE OPTION OPTIONALLY OR ORDER OUT OUTER OUTFILE PRECISION PRIMARY PRIVILEGES PROCEDURE PURGE READ REAL REFERENCES REGEXP RENAME REPEAT REPLACE REQUIRE RESTRICT RETURN RETURNS REVOKE RIGHT RLIKE RTREE SELECT SENSITIVE SEPARATOR SET SHOW SMALLINT SOME SONAME SPATIAL SPECIFIC SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT SSL STARTING STRAIGHT_JOIN STRIPED TABLE TABLES TERMINATED THEN TINYBLOB TINYINT TINYTEXT TO TRAILING TRUE TYPES UNION UNIQUE UNLOCK UNSIGNED UNTIL UPDATE USAGE USE USER_RESOURCES USING VALUES VARBINARY VARCHAR VARCHARACTER VARYING WARNINGS WHEN WHERE WHILE WITH WRITE XOR YEAR_MONTH ZEROFILL dbConnectIDdbConnectPassdbConnectUser MySQL Client ULucida Grande UMonaco WMonaco UArial UArial UVerdana UVerdana UVerdana @UVerdana UMonaco WMonaco WArial @UVerdanacREVGeometryCachestackID1016 cREVGeneral scriptChecksumjF ,19 debugObjects breakPoints handlerListNdoLog makeConnection closeConnections showCursor formatSQL executeSQL querySQLscriptSelectionchar 2556 to 2555 bookmarks tempScript prevHandlerdoLogscript4

on doLog pData

put pData & cr after fld "Data"

set the scroll of fld "Data" to 30000

end doLog

on makeConnection

put the dbConnectName of this stack into dbName

put the dbConnectAddr of this stack into dbHost

put the dbConnectUser of this stack into dbUser

put the dbConnectPass of this stack into dbPass

get revOpenDatabase("MySQL",dbHost,dbName,dbUser,dbPass)

if it is a number then

set the dbConnectID of this stack to it

doLog "Connected to " & dbName & ", ID = " & it

set the label of btn "Connect" to "Disconnect"

else

set the dbConnect of this stack to empty

answer it

end if

end makeConnection

on closeConnections

set the dbConnectID of this stack to empty

put revOpenDatabases() into dbList

repeat for each item d in dbList

revCloseDatabase d

doLog "Disconnected from ID = " & d

end repeat

end closeConnections

on showCursor curID

put "-" into tDiv

put revDatabaseColumnCount(curID) into colNum

repeat colNum times

put "--------------|" after tDiv

end repeat

put revDatabaseColumnNames(curID) into colNames

replace comma with tab & "|" in colNames

put tDiv & cr & colNames & tab & "|" & cr & tDiv & cr into curDisplay

put revNumberOfRecords(curID) into recNum

if recNum > 0 then

repeat

repeat with c = 1 to colNum

put revDatabaseColumnNumbered(curID, c) into temp

if temp is empty then put "NULL" into temp

put temp & tab & "|" after curDisplay

end repeat

put cr after curDisplay

revMoveToNextRecord curID

if the result = false then exit repeat

end repeat

end if

put tDiv after curDisplay

revCloseCursor curID

doLog curDisplay

end showCursor

function formatSQL pQuery

put the mySQLreservedWords of this stack into tWords

put empty into newQuery

replace cr with space in pQuery

if last char of pQuery = ";" then delete last char of pQuery

repeat for each word W in pQuery

if tWords contains W then

put toUpper(W) & space after newQuery

else

put W & space after newQuery

end if

end repeat

delete last char of newQuery

if word 1 of newQuery is in "SELECT,DESCRIBE,SHOW" then put ";" after newQuery

return newQuery

end formatSQL

on executeSQL

put formatSQL(fld "Query") into fld "Query"

put fld "Query" into dbSQL

doLog "> " & dbSQL

revExecuteSQL the dbConnectID of this stack, dbSQL

if the result is a number then

doLog "Query OK: " & the result & " record(s) altered."

else

doLog the result

end if

end executeSQL

on querySQL

put formatSQL(fld "Query") into fld "Query"

put fld "Query" into dbSQL

doLog "> " & dbSQL

put revQueryDatabase(the dbConnectID of this stack, dbSQL) into curID

if curID is a number then

showCursor curID

else

doLog curID

end if

end querySQL

 @&cREVGeometryCacheIDs10566969740301010105669557857110081056695553166100510566955451661003105744499186210161057444950635101510574447273191014cREVGeometrycacheorderb1056695545166 1057444991862 1056695553166 1056695578571 1056696974030 1057444727319 1057444950635 total7 cREVGeneral bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script Data)pon mouseUp if word 1 of the selectedText of me = ">" then put word 2 to -1 of the selectedText of me into fld "Query" end if end mouseUp i cREVGeometryMaster,scalebottomObjectSideBottomMaster,movehDistancefalseMaster,scaleBottomscaleBottomtrueMastertrueMaster,scaleLeftObjectRefcardMaster,scaleTopObjectRefcardMaster,scalebottomObjectRefcardMaster,scalebottomAbsolutetrueMaster,scalebottomtrueMaster,scaleLeftObjectSideLeftMaster,scaleTopObjectSideTopMaster,movevDistancefalseMaster,scalebottomDistance-92Master,expectedRect 8,8,440,338Master,scaleRightAbsolutetrueMaster,scaleRighttrueMaster,scalerightDistance-10Master,scaleLeftAbsolutetrueMaster,scaleTopAbsolutetrueMaster,scaleRightObjectSideRightMaster,scaleRightObjectRefcardMaster,scaleLefttrueMaster,scaleToptrueMaster,cardRanking4Master,scaletopDistance8Master,scaleleftDistance8 cREVGeneralscriptChecksumrH~SjJyW bookmarks revUniqueID 1056695545166 handlerListmouseUpscriptSelectionchar 133 to 132 prevHandler tempScriptscript

on mouseUp

if word 1 of the selectedText of me = ">" then

put word 2 to -1 of the selectedText of me into fld "Query"

end if

end mouseUp

 ` na vConnectepon mouseUp if the label of me = "Connect" then go to stack "Connect" as sheet else closeConnections set the label of me to "Connect" end if end mouseUp RConnect cREVGeometryMaster,scaleBottomObjectSideBottomMaster,moveVObjectSidebottomMaster,movehDistance -0.903846Master,scaleBottomscaleBottomtrueMastertrueMaster,scaleBottomObjectRefcardMaster,moveVObjectRefcardMaster,movehObjectRefcardMaster,scaleBottomAbsolutefalseMaster,moveVAbsolutetrueMaster,scaleBottomfalse Master,moveVtrueMaster,movevDistance-15Master,scalebottomDistance -0.006135Master,expectedRect 8,469,90,492Master,movehObjectSiderightMaster,scalerightDistanceMaster,cardRanking2Master,scaletopDistanceMaster,scaleleftDistanceMaster,movehAbsolutefalse Master,movehtrue cREVGeneralscriptChecksumubf>z76O revUniqueID 1056695578571 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 144 to 143scriptr

on mouseUp

if the label of me = "Connect" then

go to stack "Connect" as sheet

else

closeConnections

set the label of me to "Connect"

end if

end mouseUp

ClearEpoon mouseUp put empty into fld "Data" if the optionKey is down then put empty into fld "Query" end mouseUp R cREVGeometryMaster,moveVObjectSidebottomMaster,movehDistance -0.641026MastertrueMaster,moveVObjectRefcardMaster,movehObjectRefcardMaster,moveVAbsolutetrue Master,moveVtrueMaster,expectedRect141,469,223,492Master,scalebottomDistanceMaster,movevDistance-15Master,movehObjectSiderightMaster,scalerightDistanceMaster,cardRanking2Master,scaleleftDistanceMaster,scaletopDistanceMaster,movehAbsolutefalse Master,movehtrue cREVGeneralscriptChecksum,bz revUniqueID 1056696974030 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 98 to 97script

on mouseUp

put empty into fld "Data"

if the optionKey is down then put empty into fld "Query"

end mouseUp

Query)pAon enterInField send mouseUp to btn "Do It" end enterInField / cREVGeometryMaster,scaleBottomObjectSideBottomMaster,moveVObjectSidebottomMaster,movehDistancefalseMaster,scaleBottomscaleBottomtrueMastertrueMaster,scaleLeftObjectRefcardMaster,scaleTopObjectRefcardMaster,scaleBottomObjectRefcardMaster,moveVObjectRefcardMaster,scaleBottomAbsolutefalseMaster,moveVAbsolutetrueMaster,scaleBottomfalse Master,moveVtrueMaster,scaleLeftObjectSideLeftMaster,scaleTopObjectSideTopMaster,movevDistance-55Master,scalebottomDistance -0.063395Master,expectedRect 8,352,440,399Master,scaleRightAbsolutetrueMaster,scaleRighttrueMaster,scalerightDistance-10Master,scaleLeftAbsolutetrueMaster,scaleRightObjectSideRightMaster,scaleRightObjectRefcardMaster,scaleTopAbsolutetrueMaster,scaleLefttrueMaster,scaleTopfalseMaster,cardRanking3Master,scaletopDistance411Master,scaleleftDistance8 cREVGeneralscriptChecksum(ORRJr7 ژ\ bookmarks revUniqueID 1056695553166 handlerList enterInFieldscriptSelection char 47 to 46 prevHandler enterInField tempScriptscriptq

on enterInField

send mouseUp to btn "Do It"

end enterInField

 ` -Do Itpon mouseUp if word 1 of fld "Query" is in "SELECT,DESCRIBE,SHOW" then querySQL else executeSQL end if end mouseUp R cREVGeometryMaster,moveVObjectSidebottomMaster,scaleBottomObjectSideBottomMaster,scaleBottomscaleBottomtrueMaster,movehDistance -0.113782Master,scaleRightscaleBottomtrueMastertrueMaster,moveVObjectRefcardMaster,scaleBottomObjectRefcardMaster,moveHObjectRefcardMaster,moveVAbsolutetrueMaster,scaleBottomAbsolutefalse Master,moveVtrueMaster,scaleBottomfalseMaster,expectedRect512,463,594,486Master,scalebottomDistance -0.006135Master,movevDistance-15Master,moveHObjectSiderightMaster,scaleRightAbsolutefalseMaster,scaleRightfalseMaster,scalerightDistance -0.048077Master,scaleRightObjectSideRightMaster,scaleRightObjectRefcardMaster,cardRanking2Master,moveHAbsolutefalseMaster,scaleleftDistanceMaster,scaletopDistance Master,moveHtrue cREVGeneralscriptChecksum{S-*F{b bookmarks revUniqueID 1057444727319 handlerListmouseUpscriptSelection char 38 to 37 prevHandlermouseUp tempScriptscript^

on mouseUp

if word 1 of fld "Query" is in "SELECT,DESCRIBE,SHOW" then

querySQL

else

executeSQL

end if

end mouseUp

HelppWon mouseUp set the visible of fld "Help" to not the visible of fld "Help" end mouseUp .R cREVGeometryMaster,moveVObjectSidebottomMaster,scaleBottomObjectSideBottomMaster,scaleBottomscaleBottomtrueMaster,movehDistance -0.376603Master,scaleRightscaleBottomtrueMastertrueMaster,moveVObjectRefcardMaster,scaleBottomObjectRefcardMaster,moveHObjectRefcardMaster,moveVAbsolutetrueMaster,scaleBottomAbsolutefalse Master,moveVtrueMaster,scaleBottomfalseMaster,expectedRect348,463,430,486Master,scalebottomDistance -0.006135Master,movevDistance-15Master,moveHObjectSiderightMaster,scaleRightAbsolutefalseMaster,scaleRightfalseMaster,scalerightDistance -0.310897Master,scaleRightObjectSideRightMaster,scaleRightObjectRefcardMaster,cardRanking2Master,moveHAbsolutefalseMaster,scaleleftDistanceMaster,scaletopDistance Master,moveHtrue cREVGeneralscriptChecksum$8nbTֹꚱ revUniqueID 1057444950635 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 74 to 73script

on mouseUp

set the visible of fld "Help" to not the visible of fld "Help"

end mouseUp

Help!xon linkClicked pLink if pLink contains "@" then revGoURL "mailto:" & pLink else revGoURL pLink end if end linkClicked on mouseUp hide me end mouseUp  cREVGeometryMaster,scaleBottomObjectSideBottomMaster,movehDistancefalseMastertrueMaster,scaleLeftObjectRefcardMaster,scaleTopObjectRefcardMaster,scaleBottomObjectRefcardMaster,scaleBottomAbsolutetrueMaster,scaleBottomtrueMaster,scaleLeftObjectSideLeftMaster,scaleTopObjectSideTopMaster,expectedRect 8,8,614,458Master,scalebottomDistance-31Master,movevDistancefalseMaster,scaleRightAbsolutetrueMaster,scaleRighttrueMaster,scalerightDistance-10Master,scaleRightObjectRefcardMaster,scaleRightObjectSideRightMaster,scaleLeftAbsolutetrueMaster,scaleTopAbsolutetrueMaster,scaleLefttrueMaster,scaleToptrueMaster,cardRanking4Master,scaleleftDistance8Master,scaletopDistance8 cREVGeneralscriptChecksumADHn >,M bookmarks revUniqueID 1057444991862 handlerListlinkClicked mouseUpscriptSelectionchar 154 to 153 prevHandler linkClicked tempScriptscript

on linkClicked pLink

if pLink contains "@" then

revGoURL "mailto:" & pLink

else

revGoURL pLink

end if

end linkClicked

on mouseUp

hide me

end mouseUp

 MySQL Client:  This stack is a client for MySQL which is designed to be very like the client that can be used from the OS X Terminal. Since I am now using MySQL on a remote server, I didn't have the client installed on my desktop computer, so I needed a way to interact directly with the MySQL Server. Connecting to the Server:   2Click 'Connect' to enter your connection details. 7The last connection will be remembered for future use. `If you are connecting to a MySQL Server on your own computer, type 'localhost' for the address. Querying the Server:   TType any SQL command in the field at the bottom and press 'Enter' or click 'Do It'. MySQL reserved words will be changed to upper-case, a semi-colon will be added if required and the command will be checked to see whether it is a query or an executable command. _The relevant Revolution database handler or function will be called and the results displayed. `For a query, the results are displayed in table form with dividers like those used in Terminal. DFor executable commands, the number of rows affected will be shown. Disconnecting:   SWhen you have finished, click 'Disconnect' to break your connection to the Server. Other information:   - Clicking on any line in the results display that starts with a '>', will bring the selected command back into the command field at the bottom, where it can be edited or re-run. - 'Clear' will normally only clear the results display, but if you Option-click, it will also clear the command field at the bottom. - This has only been tested on Mac OS X 10.2.6, Rev 2.0.1 and with MySQL 4.0, but I would be interested to hear if anyone uses it on other systems. - If you want a more structured method of interacting with a MySQL Server, then you might be interested in my other MySQL utility stack: MySQL tests.rev which is also available on my web site. h- Feel free to use or modify this stack in any way, but anything you do with it is your responsibility. 7Sarah Reichelt sarah@troz.net http://www.troz.net/Rev/       ` ConnectRz ULucida GrandecREVGeometryCachestackID1015 cREVGeneralscriptChecksumُ B~ bookmarks handlerList tempScript prevHandler preOpenStackscriptSelection char 1 to 0script

 Pon preOpenStack put the dbConnectName of stack "MySQL" into fld "dbName" put the dbConnectAddr of stack "MySQL" into fld "dbAddr" put the dbConnectUser of stack "MySQL" into fld "dbUser" put the dbConnectPass of stack "MySQL" into dbPass put dbPass into fld "hiddenPass" put the length of dbPass into lenPass put char 1 to lenPass of "" into fld "dbPass" end preOpenStack on clearFields put empty into fld "dbName" put empty into fld "dbAddr" put empty into fld "dbUser" put empty into fld "dbPass" put empty into fld "hiddenPass" end clearFields on openField put the target select the text of the target end openField cREVGeometryCacheIDs 105695203854810131057025449661101510569518985201006105695197838910101056951967941100810569519756141009105695189550510051056952027718101210569519024211007105695206031810141056951980515101110569518703461004cREVGeometrycachetotal12order  cREVGeneralscriptChecksumr[r\[ bookmarks handlerList"preOpenStack clearFields openFieldscriptSelectionchar 636 to 635 prevHandler clearFields tempScriptscript

on preOpenStack

put the dbConnectName of stack "MySQL" into fld "dbName"

put the dbConnectAddr of stack "MySQL" into fld "dbAddr"

put the dbConnectUser of stack "MySQL" into fld "dbUser"

put the dbConnectPass of stack "MySQL" into dbPass

put dbPass into fld "hiddenPass"

put the length of dbPass into lenPass

put char 1 to lenPass of "••••••••••••••••••••••••••••••••" into fld "dbPass"

end preOpenStack

on clearFields

put empty into fld "dbName"

put empty into fld "dbAddr"

put empty into fld "dbUser"

put empty into fld "dbPass"

put empty into fld "hiddenPass"

end clearFields

on openField

put the target

select the text of the target

end openField

 Field 1 ' cREVGeneral revUniqueID 1056951870346 Database name: Field 1 B cREVGeneral revUniqueID 1056951895505 Database address: Field 1 \ cREVGeneral revUniqueID 1056951898520 Login name: Field 1 w cREVGeneral revUniqueID 1056951902421 Password: dbNamei`) cREVGeneral revUniqueID 1056951967941  dbAddri`D cREVGeneral revUniqueID 1056951975614  dbUseri`^ cREVGeneral revUniqueID 1056951978389  dbPassipon closeField put me into fld "hiddenPass" put the length of me into lenPass put char 1 to lenPass of "" into me end closeField y cREVGeneralscriptChecksum0Ÿ Id MY bookmarks revUniqueID 1056951980515 handlerList closeFieldscriptSelectionchar 151 to 150 prevHandler tempScriptscriptP

on closeField

put me into fld "hiddenPass"

put the length of me into lenPass

put char 1 to lenPass of "••••••••••••••••••••••••••••••••" into me

end closeField

 CancelEpKon mouseUp clearFields save this stack close this stack end mouseUp R cREVGeneralscriptChecksum;@5 ; revUniqueID 1056952027718 bookmarks handlerListmouseUp tempScript prevHandlerscriptSelection char 62 to 61scriptl

on mouseUp

clearFields

save this stack

close this stack

end mouseUp

ConnectMpKon mouseUp set the dbConnectName of stack "MySQL" to fld "dbName" set the dbConnectAddr of stack "MySQL" to fld "dbAddr" set the dbConnectUser of stack "MySQL" to fld "dbUser" set the dbConnectPass of stack "MySQL" to fld "hiddenPass" clearFields close this stack send makeConnection to stack "MySQL" end mouseUp "R cREVGeneralscriptChecksum\XBb revUniqueID 1056952038548 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 238 to 237script

on mouseUp

set the dbConnectName of stack "MySQL" to fld "dbName"

set the dbConnectAddr of stack "MySQL" to fld "dbAddr"

set the dbConnectUser of stack "MySQL" to fld "dbUser"

set the dbConnectPass of stack "MySQL" to fld "hiddenPass"

clearFields

close this stack

send makeConnection to stack "MySQL"

end mouseUp

Field 2 P cREVGeneral revUniqueID 1056952060318 Enter the connection settings.  hiddenPass`@j cREVGeneral revUniqueID 1057025449661