HELP! Using Shared Code between Desktop and Web

Hi,

I have shared (External) code and on the Desktop that I use on Web.

The desktop has a function:

MigrateAllUsers( lsAction as String, Prog as ProgressBar = Nil, lbl as Label = Nil)

The problem is ProgressBar is only in Desktop. This function is only used in Desktop App.

Is there a way to make this code Disappear if the external code is used in a web app? Like with a Compiler directive?

I hope this is clear.

you make 2 methods with the same name, one with progressbar, the other with webprogressbar (or nothing) as parameter
then in the second page of the inspector, you uncheck web or desktop to compile only for the needed paltform.

I unchecked the web option In inspector and now it doesn’t compiles in the web option.

A few ways to handle this:

  • make two methods with different signatures (you can then set the Insepector/Gear Icon/Attributes/Include In flags to choose only Web or Desktop for each method)
  • one method that uses Variants, then internally switches on type:
MigrateAllUsers(iSAction as String, ProgV as Variant = nil, lblV as Variant = nil)
#if TargetWeb
  dim prog as WebProgressBar = progV
#else
  dim prog as ProgressBar = progV
#end if
 prog.value = 32
  [...]

Perhaps use a compiler directive to define the correct object?

oh… @Michael Diehr beat me to the line. +1 on his suggestion.