TargetWindows

What has happened to “TargetWindows”? I write
#If TargetWindows Then
which is copied right out of the docs, and I get the error
“This method or property doesn’t exist” with “TargetWindows” highlighted.

uh … nothing … I use this all the time

where are you putting this ?

For the end if
Use #EndIf

TargetWin32 is the older version - same thing but deprecated in 2018
Which version of Xojo are you using?

Right before a
#If TargetMacOS Then
which works just fine.
And of course there’s a #endif

2016r4.1

TargetWindows was added in 2015r4, so it ought to work in 2016r4.1.

In my quick test with 2016r4.1 on Mac, this code worked fine:

#If TargetWindows Then MsgBox("Windows") #Else MsgBox("Not Windows") #Endif

Can you post a few lines of your code?

Also, note that the “Then” for a #if ... #endif is optional (like it should be for normal If :P)

[quote=433843:@Paul Lefebvre]In my quick test with 2016r4.1 on Mac, this code worked fine:

#If TargetWindows Then
MsgBox(“Windows”)
#Else
MsgBox(“Not Windows”)
#Endif[/quote]

I turned that around, and it works fine.

#If TargetMacOS Then
MsgBox(“Mac”)
#Else
MsgBox(“Windows”)
#Endif

I never have liked Windows.

How would you code a single line if then else statement?

If i = 1 msgbox("i = 1") else msgbox("i isn't one")

Like you I suspect, I don’t use single line If statements, but that’s my coding style - I prefer verbose (easy to read) vs smart (mostly incomprehensible requiring lots of comments that the coder thinks aren’t necessary).

And I would have to say verbose is a damn site easier to debug than compact.

I agree completely with that, but even more go back to that code two years later and try to track down an obscure bug. That’s why I comment my code profusely. I often write the comments first, describing step-by-step what I want to do, then go back and fill in the code.

[quote=433883:@Wayne Golding]How would you code a single line if then else statement?

If i = 1 msgbox("i = 1") else msgbox("i isn't one")

[/quote]

MsgBox(if(i = 1,"i = 1","i isn't one"))

I don’t know if it is harder to debug but more the way we learned. Maybe a kid learning to code and using this way more than the verbose one could say it is easier to code for them? Don’t know.

Something this simple I might code just as a single line, but if it was actually a complex test and complex resulting procedures, I might write in this form:

if i = 1 then ’ Is the index at the origin?
MsgBox “We are starting at the beginning” ’ yes
else
MsgBox “Continuing the process” ’ no
end

I remember in the 70’s when APL was implemented. The challenge for students was to write an extremely complex procedure in one statement. It’s impossible for someone else to support such code.

[quote=433917:@Dan Paymar]
I remember in the 70’s when APL was implemented. The challenge for students was to write an extremely complex procedure in one statement. It’s impossible for someone else to support such code.[/quote]

Been there done that rewrote all the greek :stuck_out_tongue:
That was one of my very first assignments in my very first job out of university - and I only GOT th job because I had put that I had done a course in APL.

That one got filed under “Things you wish you never put on your resumé” :stuck_out_tongue:

I’ll just drop this here as a tempting nugget :smiley:

https://www.ioccc.org

There are some examples in the Xojo docs that could be in competition in an obfuscation contest. Why don’t they use more comments? I comment almost every line of my code.

[quote=433985:@Tim Jones]I’ll just drop this here as a tempting nugget :smiley:

https://www.ioccc.org[/quote]
If you’ve never had the pleasure of APL well … it makes obfuscated C almost look readable :stuck_out_tongue:
The examples on the wikipedia page just scratch the surface https://en.wikipedia.org/wiki/APL_(programming_language)
There are many more here https://en.wikipedia.org/wiki/APL_syntax_and_symbols
All are just odd to read for anyone not at least familiar with the language - its just compact & terse :slight_smile:

Heh creating HTML in APL

      txt?'<html><body><p>This is <em>emphasized</em> text.</p></body></html>'
      {? /? ~{???\\?}??'<>'} txt
This is emphasized text.

awesome

EDIT : Pascals triangle

      Pascal?{0~¨?a????¨0,¨¨a?!¨a????}   ? Create one-line user function called Pascal
      Pascal 7                            ? Run function Pascal for seven rows and show the results below:

and thats the full implementation + comments
AND the second line is executing it 7 levels deep :stuck_out_tongue:

That’s even worse than coding in sexidecimal on the G-15

it was pure hell to convert a financial modelling app into something “readable” - a very cobol-like language that stayed in use for the better part of the next decade