Author Topic: ?ELSEIF  (Read 1672 times)

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
?ELSEIF
« on: 2012-Feb-24 »
Ok so you can use ?IFDEF to define functions specifically for a device. Most of the time I use this for iOS plugins like the following:-
Code: (glbasic) [Select]
?IFDEF IPHONE

IMPORT "C" const char* DeviceName()
IMPORT "C" void EnableAutoLock(int value)

?ELSE

FUNCTION DeviceName%:
ENDFUNCTION
FUNCTION EnableAutoLock%: value%
ENDFUNCTION

?ENDIF
Ok that's fine. So if it's IPHONE it will do proper C calls, and otherwise it will do standard functions that return nothing (because the iOS functions don't relate to anything non-iOS).

But what happens if you have say code to do the same functionality for a different device? Ok you could use ?IFDEF again for each device, but the ?ELSE is gone out of the window surely (defined twice for the iPhone basically because is an ?ELSE on the other device)?

Ideally ?ELSEIF would be perfect (unless you handle all devices manually with ?IFDEF).

So let's say you had the code for the above function for IPHONE, WEBOS, and ANDROID (but NOTHING else), you would then have something like this:-
Code: (glbasic) [Select]
?IFDEF IPHONE

IMPORT "C" const char* DeviceName()
IMPORT "C" void EnableAutoLock(int value)

?ELSEIF WEBOS

Blah blah WEBOS specific code

?ELSEIF ANDROID

Blah blah ANDROID specific code

?ELSE

FUNCTION DeviceName%:
ENDFUNCTION
FUNCTION EnableAutoLock%: value%
ENDFUNCTION

?ENDIF
Good idea no? Unless I've missed something and someone can point me in the correct direction.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

MrTAToad

  • Guest
Re: ?ELSEIF
« Reply #1 on: 2012-Feb-25 »
Yes, ?ELSEIF would be useful

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: ?ELSEIF
« Reply #2 on: 2012-Mar-20 »
added to the list. You know, that 105 MB .txt file called "todo.txt" ;)

No, really, this has good chances to get implemented, for I also really hate the typing work it causes me currently.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: ?ELSEIF
« Reply #3 on: 2012-Sep-05 »
OK, inserted to V11.