Help converting from pbasic to Arduino c++

I’m trying to drive a 4 digit led display that works with this BS2 pbasic code but can’t get it to work on the Arduino. Any help you can provide would be helpful.

' HC4LED.BS2 
' {$STAMP BS2} 
' {$PBASIC 2.5} 
Clock PIN 13 ' HC4LED module's Clock pin 
Dat PIN 11 ' HC4LED modules's Data pin 
value VAR Word ' Required; Holds value to display 
zeros VAR Bit ' Required; Determines if leading zeros are displayed 
cnt VAR Byte ' Required; Used by display routines 
segments VAR Byte (4) ' Required; Used by display routines & customer chars 
' 
DO ' Repeat forever 
FOR value = 0 TO 1000 ' Count from 0 to 1000 
GOSUB DisplayValue ' Display count on HC4LED module 
PAUSE 100 ' Wait 0.1 seconds 
NEXT ' Next count 
PAUSE 1000 ' Wait 1 second 
segments(0) = 28 ' 7 ' Setup to display "72°F" 
segments(1) = 109' 2 
segments(2) = 15 ' ° 
segments(3) = 71 ' F 
GOSUB DisplaySegments ' Display custom characters 
PAUSE 2000 ' Wait 2 seconds 
LOOP ' Repeat forever 
STOP 
DisplayValue: 
' Call with: 
' value = (value to display) 
' zeros = (0=No leading zeros; 1=Show leading zeros) 
FOR cnt = 0 TO 4 
LOOKUP value DIG cnt, [126,24,109,61,27,55,115,28,127,31],segments(3-cnt) 
NEXT 
IF zeros = 0 THEN 
IF segments(0) = 126 THEN 
segments(0) = 0 
IF segments(1) = 126 THEN 
segments(1) = 0 
IF segments(2) = 126 THEN 
segments(2) = 0 
ENDIF 
ENDIF 
ENDIF 
ENDIF 
DisplaySegments: 
' Call with: 
' segments(0) thru segments(3) set to custom character values 
' segments(0) is on the left; segments(3) is on the right 
SHIFTOUT Dat, Clock, MSBFIRST,[segments(3), segments(2), segments(1), (segments(0) >> 1)\7] 
Dat = segments(0) & 1 
HIGH Clock 
' Clock MUST remain high for at LEAST 1 millisecond for the 
' new data to be latched onto the display. 
PAUSE 1 
RETURN

And this is what I have so far (it does not display correctly but does change the display)

int Clock = 3;  // HC4LED module's Clock pin 
int Dat   = 2;  // HC4LED modules's Data pin 
int value;       // Required; Holds value to display 
int zeros;      // Required; Determines if leading zeros are displayed 
int cnt;         // Required; Used by display routines 
int segment[4]; // Required; Used by display routines & custom chars 
byte digit[10] = {126, 24, 109, 61, 27, 55, 115, 28, 127, 31}; 
bool debug = true; 
void setup() 
{ 
  pinMode (Clock, OUTPUT); 
  pinMode (Dat, OUTPUT); 
  Serial.begin(9600); 
} 

void loop() 
{ 
  int x; 
  for(x = 0; x <= 1000; x++) // Count from 0 to 1000 
  { 
    DisplayValue(x, 0); // Display count on HC4LED module 
    delay (1000); // Wait 1.0 seconds 
  } // Next count 
  delay(1000); // Wait 1 second 
//  segment[0] = 28; // 7 ' Setup to display "72°F" 
//  segment[1] = 109;// 2 
//  segment[2] = 15; // ° 
//  segment[3] = 71; // F 
//  DisplaySegments(); // Display custom characters 
//  delay(2000); // Wait 2 seconds 
} 

void DisplayValue(int value, int zeros) 
{ 
// Call with: 
// value = (value to display) 
// zeros = (0=No leading zeros; 1=Show leading zeros) 

   segment[0] = digit[value / 1000]; 
   segment[1] = digit[(value - (segment[3] * 1000)) / 100]; 
   segment[2] = digit[(value - ((segment[3] * 1000)+(segment[2] * 100))) / 10]; 
   segment[3] = digit[value - ((segment[3] * 1000)+(segment[2] * 100)+(segment[1] * 10))]; 
  

  if (zeros = 0) 
  { 
    if (segment[0] = 126) 
    { 
      segment[0] = 0; 
      if (segment[1] = 126) 
      { 
        segment[1] = 0; 
        if (segment[2] = 126) 
        { 
          segment[2] = 0; 
        } 
      } 
    } 
  } 
  DisplaySegments(); 
} 

void DisplaySegments() 
{ 
  int seg; 
// Call with: 
// segment[0] thru segment[3] set to custom character values 
// segment[0] is on the left; segment[3] is on the right 
  for(seg = 3;seg > 0;seg--) 
  { 
    if (debug) 
    { 
  //    Serial.print(seg); 
      Serial.print(" - "); 
      Serial.print(segment[seg]); 
    } 
    shiftOut(Dat, Clock, MSBFIRST,segment[seg]); 
  } 
   if (debug) 
    { 
    //  Serial.print(seg); 
      Serial.print(" - "); 
      Serial.println((segment[0] >> 1) / 7); 
    } 
   shiftOut(Dat, Clock, MSBFIRST, (segment[0] >> 1) / 7); 
//    Dat = segment[0] & 1; 
    digitalWrite (Clock, HIGH); 
  // Clock MUST remain high for at LEAST 1 millisecond for the 
  // new data to be latched onto the display. 
  delay (10); 
}

Got it! Couple of people on the ladyada forum pointed me to some code I rewrote to work.

#define CLOCK  3  //change this to the pin where the clock is going in to
#define DATA   2  // change to the pin where the data wire is plugged in to
#define LED   13  // status led 

int led_state;
byte digit[4];
byte number[] = {  126,   //0  numerals (0-9)
                    24,   //1
                   109,   //2
                    61,   //3
                    27,   //4
                    55,   //5
                   115,   //6
                    28,   //7
                   127,   //8
                    31,   //9
                    96,   //A
                    60,   //C
                   103,   //E 
                    71,   //F
                    
};

void setup() {
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);    
}

void dispDigit(byte dig, byte flash) {
   for(int i = 0; i < 8; i++) { 
      digitalWrite(DATA, (dig & B10000000));     // select high bit 
      dig = dig << 1;                                // next bit 
      digitalWrite(CLOCK, HIGH);                  // clock high 
       if (flash) delay(1);                          // wait to set display on
      digitalWrite(CLOCK, LOW); 
   } 
} 

void parseValue(int value, int zeros){
     // Call with:
     // value = (value to display)
     // zeros = (0=No leading zeros; 1=Show leading zeros)

   digit[0] = number[value / 1000];
   digit[1] = number[(value % 1000) / 100];
   digit[2] = number[((value % 1000) % 100) / 10];
   digit[3] = number[((value % 1000) % 100) % 10];
   if (zeros == 0) {
    if (digit[0] == 126) digit[0] = 0;
    if (digit[1] == 126) digit[1] = 0;
    if (digit[2] == 126) digit[2] = 0;
  }
}

void displayValue(int value, int zeros) {
  int i;
  parseValue(value, zeros);
  for (int i = 3; i > 0; i--) {
    dispDigit((byte)digit[i],0);
  }  
  dispDigit((byte)digit[0],1);  
}  

void loop() { 

  for(int j = 0; j < 1000; j++) {  
      displayValue(j, 0);
      led_state = !led_state;
      digitalWrite(LED, led_state);
      delay(1000);
    }
}