PDA

View Full Version : Me_home


hgn98009
02-26-2004, 11:42 PM
Hi, I would like to write a macro that sets ME_HOME to 'u:/' if that disc is available. Otherwise ME_HOME should be set to 'p:/' and, if that's not available to %USERPROFILE%.

Is this possible in ME10 macro language?

Hans-Göran Gustavsson

Yannick Rouat
02-27-2004, 01:41 AM
I don't think , it's possible in me10 macro , but you can make this with a batch script.

exemple :

@ echo off
IF EXIST u:\ goto dir_u_ok
IF EXIST p:\ goto dir_p_ok

:no_dir
set ME_HOME=%USERPROFILE%
goto launch_me10

:dir_u_ok
set ME_HOME=u:\
goto launch_me10

:dir_p_ok
set ME_HOME=p:\
goto launch_me10

:launch_me10
rem Your ME10 Line command
"C:\Program Files\CoCreate\OSD_Drafting_12.00\me10.exe"

Regards

John Scheffel
02-27-2004, 12:29 PM
What is this ME_HOME you are trying to set? I searched the install directory for Drafting version 12, but could not find any mention of it. I did find the command ME_HOME_DIRECTORY, which returns the "current ME10 home directory" setting, but nothing about an environment variable.

John van Doorn
02-27-2004, 01:54 PM
Hi
The answer to your question is no, there is no such macro call.

But you can write your own load module using C or C++.

I have written such a function a while ago.
If you are interested in having a copy, let me know and I try to dig it up somewhere.

hgn98009
02-29-2004, 11:53 PM
I just wrote this macro. It is used to make sure that ME10 has a suitable start directory. On the windows platform we aren't certain that the network disks are there. The only problem at the moment is that the DISPLAY function is behaving strangely. Most of the time it says "Enter item to display". At the moment i comment out the DISPLAY lines.

Hans-Göran Gustavsson

DEFINE Go_home
INQ_ENV 10
LET Awm_os (INQ 4)
IF ((Awm_os=3) OR (Awm_os=6) OR (Awm_os=7) OR (Awm_os=8))
TRAP_ERROR
CURRENT_DIRECTORY 'U:\'
IF (CHECK_ERROR)
TRAP_ERROR
CURRENT_DIRECTORY 'P:\'
IF (CHECK_ERROR)
LET USERPROFILE (GETENV 'USERPROFILE')
CURRENT_DIRECTORY USERPROFILE
DISPLAY ('Current directory set to USERPROFILE.')
ELSE
DISPLAY ('Current directory set to P disk.')
END_IF
END_IF
ELSE
LET Me_home (GETENV 'HOME')
CURRENT_DIRECTORY Me_home
END_IF
END_DEFINE

John Scheffel
03-01-2004, 02:24 PM
Originally posted by hgn98009
I just wrote this macro. It is used to make sure that ME10 has a suitable start directory. On the windows platform we aren't certain that the network disks are there. The only problem at the moment is that the DISPLAY function is behaving strangely. Most of the time it says "Enter item to display". At the moment i comment out the DISPLAY lines.
A tip on posting code such as this, it's better to enclose it in code tags so that you don't lose the indents. Click the # button in the vB Code section to add the tags. For example:

DEFINE Go_home
INQ_ENV 10
LET Awm_os (INQ 4)
IF ((Awm_os=3) OR (Awm_os=6) OR (Awm_os=7) OR (Awm_os=8))
TRAP_ERROR
CURRENT_DIRECTORY 'U:\'
IF (CHECK_ERROR)
TRAP_ERROR
CURRENT_DIRECTORY 'P:\'
IF (CHECK_ERROR)
LET USERPROFILE (GETENV 'USERPROFILE')
CURRENT_DIRECTORY USERPROFILE
DISPLAY ('Current directory set to USERPROFILE.')
ELSE
DISPLAY ('Current directory set to P disk.')
END_IF
END_IF
ELSE
LET Me_home (GETENV 'HOME')
CURRENT_DIRECTORY Me_home
END_IF
END_DEFINE
As a convention, macro and variable names are not all caps, only the first character is capitalized (might change USERPROFILE to Userprofile), but I'm not sure if this would cause any functional problem.

I'm not sure why you are having problems with DISPLAY, but it's normally not necessary to enclose the quoted string in parenthesis unless you are performing a string operation, such as:

('Current directory is set to ' + Userprofile)

However, it should work even if not needed.

One thing I don't understand about the logic. If it finds a drive U:, it does nothing since there is no ELSE on the first IF (CHECK_ERROR). Is this what you wanted?

hgn98009
03-01-2004, 09:39 PM
The users used to have hpux machines and ME10 was being started in their home directory. The U disk points to their unix home directory. I thought that it might be nice to warn people when ME10 didnt start in the usual disk. When it does, the warning would just be a waste of time. The parenthesis was just one of the things I tested when I found that the DISPLAY sentence works only sometimes. If there are goblins in the computer, why not try to use some magic to get rid of them?

The code works every time if I run it after ME10 has started. My collegue says that macros often behaves strange when run in the start sequence of both ME10 and WorkManager. Maybe I should try a WAIT before each DISPLAY.

Hans-Göran Gustavsson

John Scheffel
03-02-2004, 02:13 PM
If you are using INPUT to load and run this macro from a file, that might be the source of the problem. We have run into a lot of odd problems because macro files loaded by INPUT were not executing the macros in the order expected. I have never really understood how Drafting handles INPUT files, but it does not necessarily finish loading and running the INPUT file before proceeding to the next command in the file that executed the INPUT command. The problem is most confusing if you have nested INPUT calls, where the main startup file INPUTs a file, which INPUTs another file, etc.

You might try using the PROMPT_LIST and TRACE commands to view the file loading and command order. See the online Help for details on using these commands.

John van Doorn
03-02-2004, 02:23 PM
Hi,

You can use INPUT IMMEDIATE 'filename'

IMMEDIATE inputs and executes commands immediately instead of appending them at the end of the queue.

John Scheffel
03-03-2004, 08:18 AM
Originally posted by John van Doorn
You can use INPUT IMMEDIATE 'filename'
This is true, but there is one irritating limitation on INPUT IMMEDIATE. From the Help documentation.
For option IMMEDIATE, the <filename> must not be a variable, and the file <filename> must exist at the time of call to INPUT IMMEDIATE.
This means that you cannot specify file names with a variable in the path. For example:

INPUT IMMEDIATE (My_folder + '/my_file.m')

will result in an " Enter 'input_filename' " message at startup. This means that you must place the file somewhere in the current search path and call it by name only, or use a hard coded full path. I have always thought this was an odd restriction. I can't think of any reason that this would not be allowed. This makes it difficult to use this option in transportable code.

Thom Ivancso
03-03-2004, 09:14 AM
One of the things that I found when wanting to run a macro after it has been INPUT is to just call the macro right after the END_DEFINE statement of that macro.

Example:

DEFINE My_macro
Your code goes here....
END_DEFINE

My_Macro {Run the macro}

This seems to take care of the when it is run in comparision to when the macro is loaded into Drafting. Just make sure to keep your dependencies correct in case one macro sets up information for another one to use.

Also I have had very little problems with running macros that are loaded from the customize file.

Cheers
Thom

Harry
03-11-2004, 11:47 PM
I change the original code of this thread to make it more universal.
It is now a part of my personal 'goodies' :)



DEFINE check_drive
PARAMETER drive_name
{check IF drivename excists}
{INPUT : drivename, "c:"}
{OUTPUT: RETURN_VAL , 0 = drive not found}
{ : , 1 = drive found}

TRAP_ERROR
CURRENT_DIRECTORY drive_name
IF (CHECK_ERROR)
LET RETURN_VAL 0
ELSE
LET RETURN_VAL 1
END_IF

END
END_DEFINE