Published on :
Macro CREATION_INTERNE

Using the IFC macro function for OS detection

This code is also available in: Deutsch Español Français
This script shows how to use the `ifc` (If Character) function encapsulated within `%sysfunc` to evaluate a boolean expression. Here, it checks the automatic macro variable `&sysscp` to determine if the operating system is Windows, returning a different character string depending on the result.
Data Analysis

Type : CREATION_INTERNE


The code does not use any data tables; it relies solely on automatic system macro variables.

1 Code Block
MACRO STATEMENT
Explanation :
The `%put` command writes to the log. `%sysfunc(ifc(...))` evaluates the condition `&sysscp=WIN`. If true, it returns the first argument ('You are using Windows!'), otherwise the second ('You are not using Windows'). It's a concise alternative to `%if %then %else` for assignments or simple displays.
Copied!
1*** The mighty IF in macro language ! ;
2%put %sysfunc(ifc(&sysscp=WIN,You are using Windows!,You are not using Windows)) ;
3 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.