Wrong thinking in a X-Platform project

Not really Off-Topic, but where to put it ?

In a multi-platform project, I have (in Application Data) three directories, one for each platform.

I added a Method to place Properties and Methods…

In the Initialize method, I set the default data OS References. Of course, I use #If Target to code for each platform.

Hopefully, I was at the same time watching TV. After a large break (stop coding / watch TV), I came back to the code, read what I wrote and was happy with it.

Time to check what I wrote (it was running on macOS, code to run for Windows results (generate an image for Windows while running on macOS).

Ch**t, I forgot to call the Initialize Method ! So, I go back to the code and my eye was reading it… Leaping Lizards ! This cannot works ! The other platform code can only be fired while running in each other platform!!

Even with the “how do I design / code this application” (Feature listing, etc.) and knowing exactly what I want to achieve, I’ve made this stupid error…

I do not coded it yet, but at App.Open time, I will check the running platform, placing this information in a global Property and initialize the code properly using that information.

“Do not watch TV while coding” ?
“This job is error prone and we only can remove it when we will fall into one” ?
“Always give the code to someone else for review” ?


Happy New Year

Anything that happens for WIndows only, appears inside

[code]#if targetwin32


Anything for Mac only, inside

[code]#if targetMacOs


The windows code does not even compile into the Mac build, and vice versa

I do not understand why you would have 3 directories of data, but thats easy to handle:

//Common values
g_IntegerValue = 34
g_AppName = "My App"

#if targetwin32
g_DataDir = specialfolder.applicationdata.child("Windata")
g_picturetype = ".BMP"
#if targetMacOs
g_DataDir = specialfolder.applicationdata.child("OSXdata")
g_picturetype = ".PNG"
//remainder of setup code

You are right Jeff.

But, the application runs on the three platforms and can generate images for each platform. What I wrote (looks like what you have above) is just plainly wrong: I need to be able to generate Windows 10 images while running in Linux / macOS / Windows 10 (same for all other platforms).

To be more clear, not only I have templates specific for each platform (one folder Templates for each platform), but I want to be able to save the result for all three platforms from any platform (the application running in any platform).

Nota: each platform have its own window to do the job (so use its own Templates sources, selectable). That is why I do not falled in that trap earlier.

What an idea to reformat the project; I started by the Initialize Method. I will come back to this project in some days letting the EOY days ellapsed.

EOY: End of Year :wink:


[quote=469671:@Jeff Tullin]#if targetwin32


For conditional compilation It is a better idea to use:

#If TargetWindows Then //Declares for example #Endif

And as a constant if the code could be in any platfom but only execute on one, maybe also useful in this case:

If TargetWindows Then // Windows only code not excluded from compilation. End If

[quote]For conditional compilation It is a better idea to use:
#If TargetWindows[/quote]
No difference .
Win32 does not mean ‘32bit’

Ok, but deprecated.

From Xojo Documentation:


  • This item was deprecated in version 2018r1. Please use TargetWindows as a replacement.

Deprecated in 2018r1 ? I do not care, my license stops with 2015r1 (and no 64 bits here).

Now if one day I will be able to upgrade to current version, I will change that. :wink: