passing binary data to MySQL BLOB field
Can anyone advise what the correct syntax should be to construct a MySQL INSERT query that passes variables from LiveCode when one of said variables is a binary object? I am trying to construct the statement and then use it with RevExecuteSQL. I'm particularly trying to understand the LC Dictionary note that reads, To pass binary data in a variable in the variablesList, prepend *b to the variable name. The revExecuteSQL command strips the binary marker *b and passes it to the database as binary data, rather than text data. Fair enough. My second variable in the query below, binaryObjectVar, is a binary object. So I try this: INSERT INTO Assets (`FileName`, `File`) VALUES(:1,:2), fileNameVar, *bbinaryObjectVar The result is this LC error: compilation error at line 486 (Expression: double binary operator) near *, char 24 If I try the query without using *b MySQL chokes on the binary data in binaryObjectVar and sends the following error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':1,:2,:3,:4), test_file.pdf, %PDF-1.5%...' at line 1 So I've tried a number of permutations for including *b. I've tried quotes around the variable name with *b prepended within those quotes, *b prepended before the open quote, etc. In each case, MySQL still gags on the binary data. Help! While this may sound like a misplaced MySQL syntax question, it's not. What I'm missing is how to properly prepend *b so LC sends the variable as binary data. ??? Thanks in advance, Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
vexing MySQL query problem
I am working on an app to update a MySQL database table. Unfortunately, one of the fields in the table is named Text and I can't change that because it's a long-extant table which other non-LC scripts query. I am able to update the table except when the Text field is part of the query. Hence this query won't work. do revExecuteSQL myDB, quote INSERT INTO RelevantTable (Text) VALUES (' thisText ') quote But this query does work. do revExecuteSQL myDB, quote INSERT INTO RelevantTable (URL) VALUES (' thisURL ') quote It works even though URL is a LiveCode keyword. Text is a keyword but it's also a property. I guess that is the rub? Of course, with MySQL I have the option of inserting values into the table without identifying the fields by name. The catch seems to be that using that approach I have to insert values into all the fields, including the nullable and auto-incrementing fields. As I understand it, the value null should be inserted into the auto-incrementing fields. Hence I've tried the following query. do revExecuteSQL headlinesDB, quote INSERT INTO RelevantTable VALUES (null, ' thisURL ', null, ' thisText ', null) quote This doesn't work either. Is this because null is a LC constant? If so, is there some way I can escape it in the query? Or some other, better way to phrase the query? Thanks in advance, Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: clickability in a DataGrid
Thanks, Peter Craig. It appears, Craig, that your solution is just the ticket. With your mouseUp handler in the group script, if I click on a column in the sixth row of the grid, I get the following parseable output: field [column name] 0006 Exactly what I need. Thanks. Minor sidebar question, which isn't remotely relevant for the stack in question: Does this mean DataGrids are limited to rows? Sieg Lindstrom On Jan 22, 2013, at 7:21 PM, Craig Newman wrote: Hi. There are a few ways to do this. The old fashioned way is to write in the group script: on mouseUp put the target end mouseUp You get a result that is easily deconstructed to row and column references. You can also trap the editFieldText message, or any of the row and column properties. Craig Newman ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: clickability in a DataGrid
Alas, I spoke too soon. The output on this handler correctly identifies the column by column name but the four digit integer that follows does not correspond to the row number. Sieg Lindstrom On Jan 22, 2013, at 7:21 PM, use-livecode-requ...@lists.runrev.com wrote: Hi. There are a few ways to do this. The old fashioned way is to write in the group script: on mouseUp put the target end mouseUp You get a result that is easily deconstructed to row and column references. You can also trap the editFieldText message, or any of the row and column properties. Craig Newman ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: clickability in a DataGrid
Thanks, Peter. This script works. Thank you and apologies for my earlier confusion. Sieg Lindstrom On Jan 22, 2013, at 7:21 PM, Peter Haworth wrote: Hi Craig, I tried your mouseUp Script and all I got was a reference to graphic dgalternatingrows no matter which row or column I click in. The EditFieldText trap would work but he'd have to double click the cell and I don't think that's what he had in mind. However, I think this seems to work as a scrip of the datagrid group (apologies if this ends up with asterisks all over it): *on* mouseUp pMouseBtnNum *if* pMouseBtnNum is 1 *then* *put* the dgColumn of the target,the dghilitedline of me *end* *if* *end* mouseUp lcSQL Software http://www.lcsql.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: clickability in a DataGrid
Hej Klaus, Many thanks for the tip and the link to the datagrid manual as PDF. I used too much shorthand in describing my desire to edit the content of the row. I'm trying to duplicate an admin tool that runs in Javascript on a server. The Javascript is a black box to me; I'm just trying to duplicate the functionality, so I don't want the user to have to edit rows in the datagrid, but rather select a row to edit, and then the editing will take place on a different card set up to mimic fields and buttons in the old admin tool. Now I'm on the right track. Thanks. Sieg Lindstrom On Jan 23, 2013, at 10:00 AM, Klaus on-rev wrote: well, DataGrids are extremely complex but also extremely powerful once you get to master them (more or less :-) OK, presumed you have a datagrid of type TABLE with a column named delete and when the user clicks on that column you want to delete the complete row of the datagrid, right? Deleting -Put this into the datagrids script: on mouseup ## WHAT column has been clicked? put the dgColumn of the target into tClickedColumnName ## User clicked the column delete: if tClickedColumnName = delete then ## Better ask EVERYTIME! ;-) answer Really delete? with Cancel or OK if it = Cancel then exit to top end if ## get the currently selected row put the dghilitedLines of me into tHL ## Now let the DG do the deletion dispatch DeleteLines to me with tHL end if end mouseup EDITING is definitively implemented in the default datagrid, just check editable in the inspector for the datagridand doubleclick any column to edit iits content. Or did I misunderstand your question about editing? Get the complete datagrid manual as PDF here: http://lessons.runrev.com/m/datagrid Work through the example to get the grips. I must confess that I need to re-read the docs everytime I did not work with DGs for more than one week, just too complex stuff :-D Sieg Lindstrom Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
clickability in a DataGrid
I've used LiveCode/RunRev for some time but an new to using DataGrids. What I'd like to do (for Mac/Windows users) is include a DataGrid configured as, say, four columns of data followed by two columns that are the same in each row: one that reads Delete and one that reads Edit. I'd like to set it up so that if the user clicks on Delete or Edit in a given row that then triggers handlers to either delete that row or edit the data contained in the other four columns of that row of the grid. Using a standard text field with tab-delimited data in each row, I'd use the ClickText and the ClickLine in the field script to determine what the user clicked and trigger the appropriate actions. How would one achieve this in a DataGrid? Thanks in advance! Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
MySQL standalone issues
Can anyone point me to an article or tutorial that walks thru all the considerations for making MySQL database functionality work in a standalone? I have created several apps that query a MySQL database. They work fine in the IDE but I have never been able to get them to run as standalones, from which they return a variety of error messages depending on the specific query involved. Thanks in advance, Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: MySQL standalone issues
Thanks, Pete. That gives me a clue. The LC app of primary concern to me has such a long history it started out as a HyperCard stack (and formerly interfaced with a local database, not MySQL). There are instances in which it temporarily saves data to text files to get around HyperCard's 30,000-character field length limit. That said, I have considered that aspect before, and the text files in question are included with the stack in the standalone settings, but maybe I haven't done that properly. In fact, I now realize that the text files, being of such ancient vintage, don't have .txt extensions. Now wondering if that is the root of the problem, even though this app has worked in the IDE for 7 years. Sieg Lindstrom On Mar 20, 2012, at 1:20 PM, Pete wrote: Hi Sieg, I don't know of such an article but people on this list can probably help if you give use a bit more detail about what the queries are and what error messages you are getting. There shouldn't be any SQL reasons for things not working in a standalone if they worked in the IDE so I suspect it's some LC related issue. The favorite candidate for things like this is usually relying on data being saved somewhere in the standalone, which can't be done. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: MySQL standalone issues
Pete, I investigated further. I found something strange. I copied the simple script below from lessons.runrev.com and put it in a button on a brand new stack. Saved as a standalone and it worked as designed. Next I copied the button containing the working script to my existing app and saved that as a standalone. This time it didn't open the database. Instead it returned the answer error Unable to connect to the database. revdberr, invalid database type. What could possibly cause the same button to work in a brand new stack but not work in an old one once it's saved as a standalone? Any suggestions for what to do short of recreating a stack that has many buttons and fields? Here is the script in the button in question. on mouseUp -- use a global variable to hold the connection ID so other scripts can use it global gConnectionID -- set up the connection parameters - edit these to suit your database put fake.com into tDatabaseAddress put fake_stats into tDatabaseName put fake_username into tDatabaseUser put fakepassword into tDatabasePassword -- connect to the database put revOpenDatabase(MySQL, tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult -- check if it worked and display an error message if it didn't -- set the connection ID global if tResult is a number then put tResult into gConnectionID answer info Connected to the database. cr Connection ID = gConnectionID else put empty into gConnectionID answer error Unable to connect to the database: cr tResult end if end mouseUp Thanks, Sieg Lindstrom On Mar 20, 2012, at 1:20 PM, Pete wrote: Hi Sieg, I don't know of such an article but people on this list can probably help if you give use a bit more detail about what the queries are and what error messages you are getting. There shouldn't be any SQL reasons for things not working in a standalone if they worked in the IDE so I suspect it's some LC related issue. The favorite candidate for things like this is usually relying on data being saved somewhere in the standalone, which can't be done. Pete On Tue, Mar 20, 2012 at 12:00 PM, Sieg Lindstrom s...@trackandfieldnews.comwrote: Can anyone point me to an article or tutorial that walks thru all the considerations for making MySQL database functionality work in a standalone? I have created several apps that query a MySQL database. They work fine in the IDE but I have never been able to get them to run as standalones, from which they return a variety of error messages depending on the specific query involved. Thanks in advance, Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: can't find handler error in script that worked before
Thanks, Kay. This was running in the IDE. I tried starting the IDE, then opening the stack. Still didn't work OK. Then I tried saving as a standalone and that revealed the apparent problem, which was two lines of code in another handler in the stack script. This handler also ran OK previously under RunRev. The two lines were these; not contiguous in the script. put ; . {} into findString put ; . {w, w, w} into findString Seems the compiler didn't like the semi-colons (keyword) at the front of the literal. FYI, two interesting things about this: 1) there were other put commands in the script in which a semi-colon led a literal, and they compiled OK. 2) Eventually, simply retyping the lines solved the problem. Sieg Lindstrom On Mar 3, 2012, at 9:29 PM, Kay C Lan wrote: Is this in a standalone or a stack you are running in the IDE. There is a know problem with the start-up sequence of 5.0.2 that effects some stacks when run in the IDE. To figure if this is effecting you, start the IDE, then open your stack and see if it works OK. If it does, then this was the problem. If so you just can't open your stack by double clicking it. Hopefullly this will be resolved in the next update. HTH On Sun, Mar 4, 2012 at 12:10 PM, Sieg Lindstrom s...@trackandfieldnews.comwrote: My second post tonight while I'm thinking of it. I have an app that ran flawlessly under RunRev. Now, using LiveCode 5.0.2, a handler in a button script that calls another handler in the stack script returns a can't find handler error. It was easy to fix by moving the unfindable handler into the button script, but shouldn't a button be able to call a handler in the stack script? It worked before, hasn't been modified and all variables are properly made global. Thanks. Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
en- em-dash paste from Word (followup)
I brought this up in December and got a suggestion I thought would work. Alas, it didn't. I have a parsing tool running on OSX in which I paste text from Word (Mac Office, was using 2004 in December, using 2011 now) into a field. When I paste en and em dashes (charToNums 208 and 209) disappear. It's true that pasting from Word to TextEdit and then into the LiveCode field solves the problem and these characters don't disappear. But that's a real pain if you have to do it dozens of times a day. The suggested solution was basically... put the clipboardData into tText ... then find the en and em dashes and replace as needed in tText and put tText into the relevant field. Turns out that LiveCode still doesn't see the characters. If I paste a single en- or em-dash, LiveCode sees the clipboardData as being type text but its length is 0 and charToNum of the character returns nothing. Inquiring again in case anybody knows more about clipboardData that might suggest a solution. I tried workarounds that turned these characters into plain-vanilla hyphens but the three dash types key too many actions by the parser and I wound up down an ever-more complicated trail of unintended consequences in multiple handlers, and misparsed data. This copy and paste worked fine in RunRev. Thank you. Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
can't find handler error in script that worked before
My second post tonight while I'm thinking of it. I have an app that ran flawlessly under RunRev. Now, using LiveCode 5.0.2, a handler in a button script that calls another handler in the stack script returns a can't find handler error. It was easy to fix by moving the unfindable handler into the button script, but shouldn't a button be able to call a handler in the stack script? It worked before, hasn't been modified and all variables are properly made global. Thanks. Sieg Lindstrom ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: characters lost pasting from Word To LiveCode field
Might work. Any idea if WordLib handles OSX Word 2004? I'm using that version until I'm forced not to because I have use scores of Word macros I'd have to recreate with AppleScript if I were to upgrade. Can't quite fathom why Microsoft decided to make macros in Word for the Mac incompatible with Windows Word versions. Sieg On 12/14/11 11:49 AM, Curry Kenworthy wrote: Bottom line: Microsoft does not play well with Livecode's clipboard. Other apps are fine. Why not use WordLib? Sounds like an ideal scenario for it. Current release is ANSI but next release (almost there) has very accurate Unicode! Tested with many languages. Curry K. -- WordLib: Import MS Word and OpenOffice documents http://curryk.com/wordlib.html ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
characters lost pasting from Word To LiveCode field
I use a LiveCode app (OSX) to parse text taken from Word files, glean relevant data, write records to a database and also reformat the original text in certain ways. I copy and paste text from Word into a field in my app, click a button and it does the rest, until I upgraded to 5.0x. I'll say up front the details of text encoding are not my strong suit. With earlier versions (RunRev 4.x and earlier), I'd sometimes have to write special routines to search and replace certain characters from the pasted text. For example, the em-dash, (chartonum 209), which after pasting from Word was seen by RunRev as two characters (a two-byte character?), numtochar of 32 followed by numtochar of 20 so I wrote a routine to just search and replace to numToChar of 209. My new problem is that with LiveCode 5.0x (I just upgraded to 5.02), the em-dash if pasted from a Word file instantly disappears from the text. This... Berlin, Germany, December 12 becomes this... Berlin, Germany, December 12 This probably affects other characters; I'm not yet sure which ones. Any suggestions how I can seamlessly copy and paste the em-dash and other characters like it from Word to a LiveCode field? The only workaround, very inelegant, that I've found is to copy and paste from Word to TextEdit and then from TextEdit to LiveCode app. Not a welcome extra step. Thanks in advance. Sieg ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: use-livecode Digest, Vol 99, Issue 23
Thanks Bob Mark. Bob's fix sounds like the ticket. As to whether I'd blame Microsoft or RunRev, my first inclination is to blame Microsoft. However, this is the third time I've had to retool for different handling of characters like the em dash over several updates of RunRev/LiveCode, always pasted from the same version of Word. At one time the em dash (and there are other characters with similar problems) pasted into RunRev as chartonum 20 followed by chartonum 32. Then in a later RunRev update it came in as the reverse, chartonum 32 followed by chartonum 20. Now it disappears entirely on paste. I'd also note that an em dash pasted from Open Office appears when you paste it into a field but then if you manipulate that text with a handler and put it back into the field, it shows as an invisible chartonum 21 followed by chartonum 32. The clipboard conversions have been inconsistent over time. Thanks. Sieg On 12/13/11 4:27 PM, Mark Powell wrote: Hi Sieg I have lot of fields that I have to handle like this and have found that a pasteKey handler in the field serves my purposes. It first does put the clipboardData[text] into tTemp followed by various filtering and replacement, followed by put tTemp into me Which of course replaces the field with what you are pasting. If you want to append or insert, then a different put is needed. On 12/13/11 4:27 PM, Bob Sneidar wrote: Pasting from Office applications has been discussed in length in prior threads, but the gist of it is, Microsoft maintains their own internal clipboard to facilitate pasting between their dissimilar applications, so that a range of cells copied from a spreadsheet can be pasted into a word document as an active link or a table object etc. When you paste in another non-Microsoft app, MS does a clipboard conversion to make it compatible with the receiving app. I believe you are discovering some of the limitations to that. Now I just copied an emdash, switched to Livecode, and then entered put chartonum(the clipboardData) into the message box and got blank. I then copied the emdash from Word, pasted it into a rich text textedit document, copied it again, then issued the same command. In the first instance I got empty. In the second I got 209. That tells me that Word is performing a clipboard conversion for Livecode that kills the character. The clipboard conversion for textedit works just fine. Whose fault is it do you ask? Beats the heck out of me! Pick a number from Runrev to Microsoft. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: connecting to MySQL database thru SSH tunnel
Thanks, Bob. I have to confess that I'm not well educated in networking. I'm a regular guy who uses livecode to facilitate tasks I perform at work. Here's a wikipedia article (yeah, know its limitations as a reference source) that includes an explanation of SSH tunneling. http://en.wikipedia.org/wiki/Tunneling_protocol We're beefing up security on our server and I'm told my app will now need to talk to the relevant MySQL database on the server thru this protocol, assuming livecode is up to the task. Are SSH tunneling and VPN synonymous? I'm not sure. The article above says this: Tunneling protocols may use data encryption to transport insecure payload protocols over a public network (such as the Internet), thereby providing VPN functionality. Thanks for the tip on the useSSL argument. If anyone has had direct experience with livecode client apps and SSH tunneling, I'd appreciate any insight. Sieg On 12/8/11 8:40 AM, Bob Sneidar wrote: Help says: Syntax: revOpenDatabase(mysql,host[:port], databaseName, [userName],[password],[useSSL], [socket], [timeout], [autoReconnect]) Notice the new useSSL argument? All you have to do now is determine if the host accepts SSL connections, and if so, on what port. I am not sure what you mean by an ssh tunnel. Are you talking about a VPN? Bob ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
connecting to MySQL database thru SSH tunnel
I have an app for managing data in a MySQL database on a remote server. It¹s worked fine for years but now I would like to route the connection thru an SSH tunnel. It uses a port number other than 3306 (PortNumberHere in the function example below). So I¹ve changed the relevant function from this... put revOpenDatabase(MySQL,madeuphost.com,myDatabaseName,UserName,myPass word) into myDB ... which works fine through a normal web connection, to this for the SSH tunnel version... put revOpenDatabase(MySQL,localhost:PortNumberHere,myDatabaseName,UserNam e,myPassword) into myDB That doesn¹t work. I get the following error message. ³Can¹t connect to local MySQL server through socket tmp/mysql.sock¹ ² I¹m using LiveCode 5.0.1 on Mac OSX. Is there a solution? Some other parameter I need to specify? I have sqlite sitting in the same directory as LiveCode. Could that be problematic? Thanks. Sieg ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode