-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBinToAscii.fmfn
61 lines (52 loc) · 1.89 KB
/
BinToAscii.fmfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
------------------------------------------------------------------------------
Purpose: Converts a text of 0's and 1's to ASCII text
Author: J. Michael Tritchler
Notes: This function was developed as part of importing and
exporting the contents of an ASCII text file stored
in a container field
Parameters:
text - The binary text to convert to ASCII text
Data Type Returned:
text
Variables:
$$asciiText - ASCII representation of the binary text
~return - Returns the ASCII representation of binary text
Depends On:
ByteToInt( text )
Revision:
Last change: 13/06/2017 by JMT
::
13/06/2017 - JMT - Removed carriage adjustment for Windows
because it was removing carriage returns
for Macs
27/09/2015 - JMT - Wrote original script
------------------------------------------------------------------------------
*/
Let (
[
// Get the current integer value of the ASCII character from the byte
$curInt = ByteToInt ( Left ( text ; 8 ) ) ;
// Convert the integer value to the corresponding ASCII character
$curChar = Char ( $curInt ) ;
// Convert the current byte to ASCII and add it to the end of
// the already converted ASCII text
$$asciiText = $$asciiText & $curChar;
// Save the ASCII text as a local variable so that the global
// variable can be cleared before exiting the function
~return = $$asciiText
];
If ( Length ( text ) > 8;
// Convert the next 8 bits to ASCII text if not at the end
// of the binary text
BinToAscii ( Right ( text ; Length( text ) - 8 ) );
// Clear the global variables and return the ASCII text if
// there are no more bytes to convert
Let(
[
$$asciiText = ""
];
~return
)
)
)