CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > CoCreate Drafting

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-26-2004, 11:42 PM
hgn98009 hgn98009 is offline
Registered User
 
Join Date: Feb 2003
Location: Sweden
Posts: 35
Me_home

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
Reply With Quote
  #2  
Old 02-27-2004, 01:41 AM
Yannick Rouat Yannick Rouat is offline
Registered User
 
Join Date: Oct 2002
Location: Mulhouse , FRANCE
Posts: 40
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
Reply With Quote
  #3  
Old 02-27-2004, 12:29 PM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
What is ME_HOME?

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 Scheffel
Reply With Quote
  #4  
Old 02-27-2004, 01:54 PM
John van Doorn's Avatar
John van Doorn John van Doorn is offline
Registered User
 
Join Date: Nov 2002
Location: The Netherlands
Posts: 83
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.
__________________
High performance CAD workstations
Please visit us at https://www.cadware.nl
Reply With Quote
  #5  
Old 02-29-2004, 11:53 PM
hgn98009 hgn98009 is offline
Registered User
 
Join Date: Feb 2003
Location: Sweden
Posts: 35
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
Reply With Quote
  #6  
Old 03-01-2004, 02:24 PM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Quote:
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:
Code:
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?
__________________
John Scheffel
Reply With Quote
  #7  
Old 03-01-2004, 09:39 PM
hgn98009 hgn98009 is offline
Registered User
 
Join Date: Feb 2003
Location: Sweden
Posts: 35
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
Reply With Quote
  #8  
Old 03-02-2004, 02:13 PM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
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 Scheffel
Reply With Quote
  #9  
Old 03-02-2004, 02:23 PM
John van Doorn's Avatar
John van Doorn John van Doorn is offline
Registered User
 
Join Date: Nov 2002
Location: The Netherlands
Posts: 83
Hi,

You can use INPUT IMMEDIATE 'filename'

IMMEDIATE inputs and executes commands immediately instead of appending them at the end of the queue.
__________________
High performance CAD workstations
Please visit us at https://www.cadware.nl
Reply With Quote
  #10  
Old 03-03-2004, 08:18 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Quote:
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.
Quote:
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.
__________________
John Scheffel
Reply With Quote
  #11  
Old 03-03-2004, 09:14 AM
Thom Ivancso's Avatar
Thom Ivancso Thom Ivancso is offline
Registered User
 
Join Date: Oct 2002
Location: Connecticut, USA
Posts: 212
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
Reply With Quote
  #12  
Old 03-11-2004, 11:47 PM
Harry Harry is offline
Registered User
 
Join Date: Jan 2004
Posts: 85
Thumbs up

I change the original code of this thread to make it more universal.
It is now a part of my personal 'goodies'


Code:
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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:28 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.