Build Automation - comment or uncomment a line

Hello,

I’ve got an app that creates a temporary table in MySQL. I can’t connect to a temp table to debug it in MySQL Workbench. So I have a line of code that creates a regular table. I comment out one or the other depending on what I need to do. Of course, I forget to go back to reset the line comments correctly in order to deliver a build. Then I get a ruckus going when the app does not work right.

Is this something I could do with a build script? It would need to find the lines and comment one or the other. Not sure how best to do this.

Thanks.

Duane Mitchell

You might be better off using a constant and setting its value with your build script.

#If UseTempTable Then
     xxx
#Else
    yyy
#Endif

or…

#if debugbuild //create a regular table #Else //create the MySQL table #Endif

If I’m not debugging on the MySQL database then I DO want it to use temp tables because it cleans up nicely, creates a table and deletes it. That’s most of the time. Otherwise, again I forget about it and it’s a pain to run the debug session and have it error because it’s a duplicate table since I run the same test data.

I think in both these suggestions it presumes I always debug with regular tables and only build with temp tables. Not the case. I mostly debug with the temp table so the line is correct. Here’s the lines.

vSQLCreateTable="CREATE TEMPORARY TABLE `"+vTableName+"` (" 'vSQLCreateTable="CREATE TABLE `"+vTableName+"` ("
It’s the beginning of a string variable that builds the CREATE for an arbitrary number of columns based on a tab delimited text file. You can see the bottom line is commented and that how I need to deliver and that’s how I work with the app the majority of the time. Only when I get into some new SQL stuff do I have to test out the SQL on the database.

Maybe if I have a boolean constant set to true then I could have code like this.

#If UseTempTable Then vSQLCreateTable="CREATE TEMPORARY TABLE `"+vTableName+"` (" #Else vSQLCreateTable="CREATE TABLE `"+vTableName+"` (" #Endif
Then if I want to debug the MySQL I could change that constant to FALSE. Then in my build script I could change it back to TRUE to catch my omission. Does that make sense? I’m not familiar with working with constants like this.

Thanks.

Yes, that’s exactly what I was getting at.

Having a little trouble here. I created a boolean constant on the App object and set it to true. Created the If…Then…Else and that works correctly when stepping through the code.

I have a build script already that codesigns the app and I put this at the top.

If app.UseTempTable = False Then app.UseTempTable = True End If

This errors. Not much info in the error message.

Can you have more than one build script?

I’ve got at least a dozen IDE scripts.

The syntax for using a constant is a bit more complex. Have a look at http://developer.xojo.com/ide-scripting-constants .

I’m trying to change a constant. I get an error that says I can’t change the value and that makes sense to me. If you could change a constant it wouldn’t be so constant.

I have a boolean constant as part of the App and it’s set to true. That is processed in an If…Then…Else to create MySQL temp tables. But I can’t debug those because they are “invisible”. So I set the constant to false and the code creates regular tables in MySQL and I can inspect them with Sequel Pro or Workbench. I want to inspect the value of the constant in a build script and set it back to true if I forget to do so manually.

Not sure what I’m missing?

Have you tried the example from the page I mentioned:

If DebugBuild Then If SelectProjectItem("App") Then ' Constant kDebugRuns must exist on App Dim value As Integer = Val(ConstantValue("kDebugRuns")) + 1 ConstantValue("kDebugRuns") = Str(value) End If End If

The values always need to be strings. Perhaps this is the problem. Try with an integer with values 0 and 1 instead.

I am working on a modification of that now. Looks promising. Thanks! I’ll get back soon.

Well not so promising. If I understand that code it should update the kDebugRuns by +1 every time I run the app in debug mode?

I’m pretty much convinced this does not work. I am trying to get the example project working using the documentation code and that is not working. Not a good sign when that doesn’t work but I may be missing something. What I am expecting is that a constant will get changed. I started with the AutoSaveScript example project included with Xojo. I added the code from the Xojo documentation to it like this.

I tried both number and string constants like these. I did try setting the dynamic to on for the string version.

There might be a problem with the documentation. This is what I’m using for my own app:

if ConstantValue("App.kMaxVersion") = "1" then

There is no need to select anything.

PS: If you add .png to the link from Imgur then the images will show up here.

I posted the wrong link from Imgur. Updated it.

Is it possible that DebugBuild is returning False?

Looks like feedback://showreport?report_id=51203.

Looks similar. I’ll look into this some more later. Thanks.

Part of my problem may be that I don’t know much about how to include build step scripts and have basically zero experience with them. For example, I did not know that the position of the script either before or after the build mattered. I thought there could be only one script and everything had to go there. That might be part of my problem that I was trying to do something pre-build in the post-build step. I’ll revisit that.

I did do my share of searching the docs, didn’t see much on this. Did I miss some examples? I looked in the webinars also.

Start here:

http://developer.xojo.com/userguide/build-automation

http://developer.xojo.com/webinar-ide-scripting