Legacy script

Hi All,

I have for my sins taken over a project to update some legacy scripts which where written in C+. The scripts read data from a serial feed and converts the data in to a CSV format for output. I am able to read all of the output apart from one section of data which is based around "time". On looking at the incoming data "serial" I think the "time" part maybe in "hexidecimal" format. Below is a section of one of the scripts, Can anyone tell if the code is looking for "Hex Time" and if so how is it trying to do it.. Any help would be great as I am not as yet a C programmer. Many thanks in advance.

Best regards, Dereck
[code]
proc htod(number)
;string(number)
int(nub, r, x, y, Dec)
nub = strlen(number)
x = 0, y = nub

alias(alHex)
alHex("A","10")
alHex("B","11")
alHex("C","12")
alHex("D","13")
alHex("E","14")
alHex("F","15")

while (x < nub)
r = val(alHex(mid(number,(x), 1)))
--y
if y == 3
Dec += r * 4096
elif y == 2
Dec += r * 256
elif y == 1
Dec += r * 16
else
Dec += r
endif
++x
endwhile
; print(Dec)
return(Dec)

proc BhxTime(hextime) ; covert hex time into hours and mins, back to a string
int(time,),string(hour ,min)

time = htod(hextime)
hour = itoa((time / 60), 2) ; convert int val back to a string
min = itoa((time % 60), 2)

if strlen(hour) == 1 ; must make time into 4 chars add 0
hour = "0" + hour
endif
if strlen(min) == 1
min = "0" + min
endif

return(hour + min)
[code]
What language is this? It's certainly not C++.
Hi PanGalactic,

Many thanks for your reply.

I was told it was C++ but you say it is not. Couyld it be any form of C , C+ ?

again, many thanks for your time.

Dereck
Python, maybe?
It isn't Python either
This resembles PHP, but it's not PHP either.
Considering this code seems rather... inconsistent, it's likely that this is mere pseudo-code.
If you have evidence that it's actually a functional piece of code, it would help if you posted which programs are used to run or compile this.
guys pls help me about my program.. my problem is i dont know how to use the 2D arrays.. pls guide my program how to random the student names and it will GROUP into three members of names. i have here a code but my problem is the the name will random into more than one, i dont know how to random it into once only and i dont know how to group it into three members of names,, pls help me guys.
heres my code..

#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;
int x, stud;
int group[36];
int check[36];

int main()
{string NameArray[36] = {"capili","roces" ,"florez","carpio","almeria","sumanting","Lim","daviza","angulo","macadangdang","tulio","abad","tejadillo","balbarona","caballes","ipong","clemente","junsay","deypalubos","lines","quino","yaun","moril","arastam","laurente","montajes","racho","david","umanan","fampulme","suratos","oliveros","tobi","madara"};

cout<< "Before the Name Random\n";

for (int i =0; i <=35; i++)

{

cout << NameArray[i] << endl;
}
cout << endl;
cout <<"After the randomizing\n";

srand( (unsigned)time(0) );
for(int j=9; j>1; j--)
{
int r = rand()%j;// produces a random # between 0 and j-1 inclusive.
// TODO: Swap elements j and r. Please work this part out
}

for (int j =0; j<=35; j++)

{
string Random;
Random = NameArray[rand()%36];
cout << Random << endl;
NameArray[j]=Random;
}

system("PAUSE");
return 0;
}
Topic archived. No new replies allowed.