dividing a string(help)

phondajphondaj Member Posts: 60
hi navision experts,
i need your help!
I have a string like that 123456789 a want to creat e variable with 2 first nambers "12", and another variable with 4 number countin from the end "6789" is that imposible on navision
or
if my string start with 12 else last 4 nomber should be 0000

thnx

Comments

  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi
    you can use STRLEN & COPYSTR functions.
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • kapamaroukapamarou Member Posts: 1,152
    Also STRPOS and EVALUATE... :D
  • phondajphondaj Member Posts: 60
    [-o< can any body give a example how it exactly work cuze i trying all the day and yet e didnt get the solituon :oops:
  • DenSterDenSter Member Posts: 8,304
    Rather than write the code for you, I'll show you how to get more information about this.

    Click on your help menu, and select "C/SIDE Reference Guide". This opens the C/SIDE Reference Guide, which has all the syntax help that you need. Go to the Search tab, type in STRPOS and click "List Topics". Now you will see the command in the lower left hand box. Put your cursor on the topic and click on "Display". Now you will see the help topic for this command in the right hand side of the C/SIDE Reference Guide. It even comes with a code sample. Do the same with STRLEN, and any other command you want to know more about.

    In the C/AL editor, press F5. On the left hand side scroll down to where it says SYSTEM. In the middle, select String, and this will display all available commands for Text variables. Type in any of these commands into the C/SIDE Reference Guide to learn about them. There are tons of code samples in there that should help you figure this kind of stuff out.

    In the beginning you don't know what all those commands are for. Don't worry neither did any of us when we first started. That's why you should read about all of them, and learn what they stand for. Good luck :mrgreen:
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I can recommend this handy reference guide: Microsoft Dynamics NAV 5.0 Quick Reference. But maybe I'm a bit biased here ;-)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DenSterDenSter Member Posts: 8,304
  • phondajphondaj Member Posts: 60
    *No. is item number

    shifra := "No.";
    teksti := 'pozicioni:';
    substring := '2700';
    pos := STRPOS(shifra, substring);
    MESSAGE(teksti, pos);

    and i mesagebox show me just teksti variable "position:"

    wher is my mistatake
  • MalajloMalajlo Member Posts: 294
    you can try with

    FirstPart := string[1] + String[2] ;


    Your mistake is in teksti := 'pozicioni:';
    IT should be teksti := 'pozicioni: %1';
    and
    MESSAGE(STRSUBSTNO(teksti, pos));
  • phondajphondaj Member Posts: 60
    speciale thnx to all
Sign In or Register to comment.