Thursday, January 14, 2016

How You Can Encode And Decode Text

Hi all,
Today I posted how you can Encode And Decode Text.


//<<----------------Encoding Text--------------------->>
//------Define parameter-------->>
Var Name DataType Subtype Length
No string Text 50
//<<------------END----------------

//------Define Return Value-------->>
Name Pass
Return Type Text
Length 50
//<<------------END----------------

//------Define Variables-------->>
Name DataType Subtype Length
Ch Char
i Integer
//<<------------END----------------
//------Define Functions-------------->>
LOCAL EncodeTxt(string : Text[50]) Pass : Text[50]
//--------------START----------------->>
FOR i := 1 TO STRLEN(string) DO
BEGIN
  Ch := string[i];
  IF (Ch < 32) OR ((Ch > 127) AND (Ch < 192)) THEN
    ERROR('its not an alphanumeric.');
  Pass[i] := 255-Ch;
END;
EXIT(Pass);
//<<----------------END-------------------


//<<----------------Decoding Text--------------------->>
//------Define parameter-------->>
Var Name DataType Subtype Length
No string Text 50
//<<------------END----------------

//------Define Return Value-------->>
Name Pass
Return Type Text
Length 50
//<<------------END----------------

//------Define Variables---------->>
Name DataType Subtype Length
Ch Char
i Integer
//<<------------END----------------
//------Define Functions-------------->>
LOCAL DecodeTxt(string : Text[50]) Pass : Text[50]
FOR i := 1 TO STRLEN(String) DO
BEGIN
  Ch := String[i];
  Pass[i] := 255-Ch;
END;
EXIT(Pass);
//<<----------------END-------------------



Thanks & Best Wishes
Binesh Singh Rajput
(MCP, MS, MCTS)

Monday, January 11, 2016

Create Code128 Bar Code in NAV 2009

Hi all,
Today I posted how you can Create Code128 Bar Code.

//------Define parameter-------->>
Var Name DataType Subtype Length
No CodeString Text 250
//<<------------END-------------------

//------Define Return Value-------->>
Name 128BCodeString
Return Type Text
Length 250
//<<------------END-------------------

//------Define Variables-------->>
Name DataType Subtype Length
Offset Integer
HighAscii Integer
Total Integer
iCounter Integer
Holder Integer
Check Integer
ASCIIValue Integer
CheckDigit Integer
Character Char
//<<------------END-------------------

//------Define Functions-------------->>
CreateCode128BFont(CodeString : Text[250]) "128BCodeString" : Text[250]
//--------------START----------------->>
CLEAR(Offset);
CLEAR(HighAscii);
CLEAR(Total);
CLEAR(iCounter);
CLEAR(Holder);
CLEAR(Check);
CLEAR(Character);
CLEAR(ASCIIValue);
CLEAR(CheckDigit);

Offset := 32;
HighAscii := 66;
"128BCodeString"[1] := Offset + HighAscii + 104;
Total := 104;

FOR iCounter := 1 TO STRLEN(CodeString) DO BEGIN
  Character := CodeString[iCounter];
  ASCIIValue := Character;
  CheckDigit := ((ASCIIValue - Offset) * (iCounter));
  Total += CheckDigit;
  "128BCodeString"[iCounter + 1] := ASCIIValue;
END;
Check := Total MOD 103;
Holder := 0;

IF (Check + Offset >= 127) THEN
  Holder := Check + Offset + HighAscii
ELSE
  Holder := Check + Offset;


"128BCodeString"[STRLEN("128BCodeString")+1] := Holder;
Holder := 106 + Offset + HighAscii;
"128BCodeString"[STRLEN("128BCodeString")+1] := Holder;

CLEAR(iCounter);
FOR iCounter := 1 TO STRLEN("128BCodeString") DO
  IF("128BCodeString"[iCounter] = 32) THEN
    "128BCodeString"[iCounter] := 177;

EXIT("128BCodeString");
//<<----------------END-------------------


Thanks & Best Wishes
Binesh Singh Rajput
(MCP, MS, MCTS)

Thursday, January 7, 2016

Get the days that are not holiday or weekend

Hi all,
Today I posted how you can Get the days that are not holiday or weekend.

// Get the days that are not holiday or weekend
//-----Define Local Parameters---------
{
Var Name DataType Subtype Length
No StartDate Date
No EndDate Date
//-----Define Return type---------
Name WorkDays
ReturnType Integer
//-----Define Local variabls---------
Name DataType Subtype Length
DateRec Record Date [where Table ID: 2000000007]
HolidayRec Record Shop Calendar Holiday     [where Table ID: 99000753]
}
//-----Define Function---------
GetWorkingDays(StartDate : Date;EndDate : Date) WorkDays : Integer
// Strat ---------------------->>
WorkDays := 0;
DateRec.RESET;
HolidayRec.RESET;

DateRec.SETRANGE("Period Type",DateRec."Period Type"::Date);
DateRec.SETRANGE("Period Start",StartDate,EndDate);
DateRec.SETRANGE("Period No.",1,5);  // Get only weekdays
IF DateRec.FINDFIRST THEN
  REPEAT
    IF NOT HolidayRec.GET('HLP',DateRec."Period Start") THEN
      WorkDays += 1;
  UNTIL DateRec.NEXT = 0;
EXIT(WorkDays);
// End <<------------------------


Thanks & Best Wishes
Binesh Singh Rajput
(MCP, MS, MCTS)


Popular Posts