Doe MaxIde Concatenation
BlitzMax Forums/BlitzMax Programming/Doe MaxIde Concatenation
| ||
I've got some realy heavy duty SQL stuff to do in Blitz, and as Blitz doesn't have a closing brace at the end of each line, [ ie: var myString:TString; ] i'm wondering if the editor has concatenation? I've never found it if so! The docs and a search of the forum havn't yielded answers so I thought i'd ask out here. The only other way for me to keep these SQL statements legible is to buld them up over multiple lines, ie: q$="SELECT FROM" q$=q$+"servers as s, " q$=q$+"racers as r, " etc This would result in impaired performance in runtime aswell as being far from ideal. I'm already using, I dunno what to call it, like a preg_replace type thingy with Bruce's excellent MySQL module ( prepared Query's and setString method ) but as this project gets more convoluted i'm concerned the code will become unreadable in Blitz. Thank you for any assistance. |
| ||
Put a ... on the end of the line and then carry on on the next line. |
| ||
Put a ... on the end of the line and then carry on on the next line. Its just .. |
| ||
the character .. does the jobq$="SELECT FROM" + .. "servers as s, " + .. "racers as r, " If I'm not wrong, this is calculated at compile time. (check the assembler generated). confirmed, the generated assembler has only one string constant, that looks like this: dd _bbStringClass dd 2147483647 dd 38 dw 83,69,76,69,67,84,32,70,82,79,77,115,101,114,118,101 dw 114,115,32,97,115,32,115,44,32,114,97,99,101,114,115,32 dw 97,115,32,114,44,32 you can see it generates a single string of 38 chars (see third mnemonic, wich indicates the length in double words (UTF) of the string). |
| ||
Ah thank you, I had not persevered enough when dealing with strings... .prepare("SELECT FROM"+.. "servers as s, "+.. "racers as r,"+.. etc Thank you for your assistance. |
| ||
BTW You can use it in for any command, for example:IF (x = y AND y = z) .. OR (y = a AND a = b) .. THEN z = b END IF Very useful when you have got a huge if statement! |
| ||
aye, whilst i'm at it with the Blitz fundamentals (it's always the basic stuff that confuses me as I switch between languages a lot, that plus i'm thick), i've done this before but it's eluding me atm... Can anyone advise me please of the way to check if a binary bit is set to true in a number, so if I was to check bit two of an TInteger.... if myInt=%0000100 where 0 could be on or off My memory tells me I do this with AND somehow, but I cant get it to compile :/ Thank you in advance |
| ||
Don't quite understand how you've worded the question, but this should helpIf myInt & %00000100 'stuff EndIf |
| ||
aha, I >think< I have it if myInt&%100 :) soz for being a moron, I was born this way before I continued to develop into even more of a muppet EDIT: Oh cheers Gfk, cross posted, but nice to know what I did is actually right |
| ||
Yeah, you don't need all the leading zeros - personally I put them in for clarity. |
| ||
Yeah I find .. useful in declaring large arrays with preset values or very long if statements. |
| ||
OK there is something I have always found frustrating with BlitzMax and I wonder if there is a solution. I tend to work with a number of source files and consequently when I compile I first have to highlight either the master file or the output window, otherwise my include will try to compile as if it is the raw source. Is there a way to specify what the 'parent' or 'master' file is to the compiler, so that if i've got a few dozen odd includes open I dont have to go hunting for the tab of the master file before I compile? I've always found that annoying, it would be great if there was a compiler hook like, CompileFile "masterFile.bmx" Thank you |
| ||
Open the file you want to be the "master". Choose, Program -> Lock Build File. :-) |
| ||
Oh my, as easy as that! All this time i've been making my life hard for myself. Thank you Brucey! *hugs* Now let me see, whilst i've got the attention of my betters... When i'm returning a result from your MySQL module in my previous project I analysed the results based upon column number. This was fine for the purpose, but my current project is more complicated and i'd like to read the results off by field name. Can your module handle this? Out of curiosity also, i'm used to using DB_DataObjects in php where you can assemble a query in a very OOP way, ie <?php $myObject = new myTableClass(); $myObject->playerName="Becky"; $myObject->find(); while ( $myObject->fetch() ){ //$myObject contains any table row with player name of Becky each cycle } Is there a module to handle access a similar way? I'm just curious really as i'm more than happy building queeries manually. |
| ||
... are you deliberately lining Brucey up to prove himself the most productive and learned BlitzMaxer? |
| ||
I'll take help from anyone who knows something I want the answer for, but it is Brucey I kinda expect is most likely to answer the above questions :P He can't be that productive though, he posts too much on the forum to actually use BlitzMax... |
| ||
i'd like to read the results off by field name. Where you would normally use record.GetInt(index), you can also use record.GetIntByName(name) - *should* work :-) ...i'm used to using DB_DataObjects in php... Is there a module to handle access a similar way? Not currently. Htbaa has done some work on something like that, and I've also considered it as a possibility at some point, but there's nothing more concrete at the moment. |
| ||
You're a star Brucey. Not a rich one, but a star all the same :P EDIT: I should warn you, i'm considering using more of your modules (BaH.Locale, BaH.libcurlSSL, BaH.Random and BaH.Crypto) which could meen the deathnail of your free time if you intend to give support ! :P |
| ||
Interestingly (or annoyingly, depending..), I don't believe the ".." line continuation feature is mentioned at all in the docs, which is probably why so many people don't know about it ;) Russell |
| ||
which is probably why so many people don't know about it You are right. I just looked over all the docs and couldn't find mention of it anywhere. A shame, considering how useful it is. I should warn you, i'm considering using more of your modules... Oh.... I guess I should start to free up some resources then ;-) You can't really go wrong with BaH.Random. Simply replace BRL with BaH in the Import, and you are done. (Other than the small issue of BRL.Basic, which imports BRL.Retro, which itself imports BRL.Random - I say, don't import BRL.Basic. Retro is so... yesterday. :-) The others... well... we'll see. |
| ||
I'm still *working* on a ORM/ActiveRecord and QueryBuilder implementation. But haven't had a lot of time for it yet. So far I can use my TQueryBuilder type to create simple INSERT, UPDATE, DELETE and SELECT queries. With my ActiveRecord implementation you can do something like: Local obj:TTableBooks = TTableBooks(new TTableBooks.Find(100)) Local str:TDBString = obj.GetColumn("author_name") 'Or Print obj.GetColumnString('author_name') But it still needs a lot of work. Currently date fields and blobs aren't supported yet. Perhaps the coming 2 weeks I have some more time for it. |
| ||
I'm using BRL.Retro eeeep! But dont worry Brucey, if something is complex I usually don't have any issues figuring it out. It's only the really simple stuff that leaves me totally dumbfounded :) |
| ||
How about requiring all statements in super strict mode be terminated with a semicolon. This would obviate the need for a special line break character, a la C/C++. Just an idea. |
| ||
How about requiring all statements in super strict mode be terminated with a semicolon. Gawd... are you volunteering to change my 100,000+ lines of source ? |
| ||
Gawd... are you volunteering to change my 100,000+ lines of source ? Er, no. Ok, maybe not have it work in super strict mode but have another mode that it works in - Uber Strict, or something. :P |