Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. nbsp; Note: This appears on each machine/browser from which this site is accessed.
Code relocatability
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. Code relocatability
In order to avoid copy-update issues whereby code is unnecessarily copied, code can be be made relocatable.
What is relocatable code?
Relocatable code is code that can determine where it is running and make appropriate decisions.
Examples:
host name
Windows or Linux
client or server
command line or web service
Python version 2 or 3
Here is the Python code.
Here is the output of the Python code.
2. Python version
3. Windows or Linux
In general, some way is needed to handle file paths between Windows and Linux.
Windows: drive letters (or UNC paths) and backward slashes
Linux: volume roots and forward slashes
I generally use a
pfix routine (for path fix) throughout the code as needed.
Other operating system commands may need to be abstracted as necessary.
4. Other discriminators
IP address
MAC address
Router IP address
5. End of page
6. Multiple choice questions for this page
4 questions omitted (login required)