Announcement

Collapse
No announcement yet.

New statements in PBDOS/PBCC for reading direct integers, floats,.... en new commands

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Phil Tippit
    replied
    Stephane,

    Well I just had to get into this, I really don't know why??

    With a little simple programming on you part, you can do the
    same thing that your PASCAL code is doing.

    What I am showing you is knowing more than doing some programming
    for yourself. The functions you use in PASCAL will create as much
    code or more in the final program. I have written programs in
    PASCAL, as far as I'm concerned it is out dated.

    I spent about 30 minutes of my time, start using some of yours.
    By the way, I charge 150.00 US for my time.

    ' This code was written in PBCC, compile it with PBCC

    Code:
    DECLARE FUNCTION PxGetMONEY$ (BYVAL a##, BYVAL chars&, BYVAL DEC&, BYVAL fchr&)
    '  A## will accept any %,!,#,@ value passed to it
    '  PowerBasic Code will Convert A!, or A as single to A##
    '  chars& = width of string returned RIGHT JUSTIFIED
    '  DEC& = Number or Decimal Placing to Use
    '  fchr& = Fill character for blank space.  Normally 32 for space
    
    FUNCTION PBMAIN() AS LONG
      a%=4578
      PRINT PxGetMoney$(a%,10,0,32)
      PRINT PxGetMoney$(a%,10,2,32)
      a!=45141.451781       ' this value doesn't meet the requirements of single
      PRINT PxGetMoney$(a!,10,0,32)
      PRINT PxGetMoney$(a!,10,2,32)
      a#=45141.451781
      PRINT PxGetMoney$(a#,10,0,32)
      PRINT PxGetMoney$(a#,10,2,32)
      PRINT PxGetMoney$(a#,10,4,32)
      a##=4514145141.451781
      PRINT PxGetMoney$(a##,20,0,32)
      PRINT PxGetMoney$(a##,20,2,32)
      PRINT PxGetMoney$(a##,20,4,32)
      a&=141451781
      PRINT PxGetMoney$(a&,20,0,32)
      PRINT PxGetMoney$(a&,20,2,32)
      PRINT PxGetMoney$(a&,20,4,32)
      a&&=141451781
      PRINT PxGetMoney$(a&&,20,0,32)
      PRINT PxGetMoney$(a&&,20,2,32)
      PRINT PxGetMoney$(a&&,20,4,32)
      [email protected]@=141451781.4578
      PRINT PxGetMoney$([email protected]@,20,0,32)
      PRINT PxGetMoney$([email protected]@,20,2,32)
      PRINT PxGetMoney$([email protected]@,20,4,32)
      [email protected]@=141451781.4578
        ' do some check writing   
      PRINT PxGetMoney$([email protected]@,20,2,42)
      
      
    
      LINE INPUT kk$
    
    END FUNCTION
    
    FUNCTION PxGetMONEY$ (BYVAL a##, BYVAL chars&, BYVAL DEC&, BYVAL fchr&)
       LOCAL c$,rsp$
       SFORMAT$ = "########################": IF fchr& = 0 THEN fchr& = 32
       IF DEC& THEN SFORMAT$ = SFORMAT$ + LEFT$(".##########", DEC& + 1)
       rsp$=RIGHT$(SPACE$(LEN(Sformat$))+FORMAT$(a##,sformat$),LEN(sformat$))
       IF DEC& AND (VAL(rsp$) >= 0 AND VAL(rsp$) < 1) THEN
          rsp$ = SPACE$(24) + RIGHT$(rsp$, DEC& + 1)
       END IF
       c$="":IF fchr&=42 THEN c$="**"
       PxGetMoney$ = RIGHT$(STRING$(chars&,fchr&)+LTRIM$(rsp$), chars&)+c$
    END FUNCTION

    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    DIM A AS INTEGER
    DIM B AS SINGLE

    A = 4578
    B = 45141.451781

    Write "this is an digit %d", a =======> 4578
    Write "This is an digit %f3.2", b =====> 451.45

    Can you please written this code in PB for me in Assembly or PB?
    Its for using in PBDOS en PBCC
    How about using the native functions that PB/DOS already contains for string and number formatting...
    Code:
    PRINT "this is an digit " + STR$(a)
    PRINT USING$("This is an digit ###.##", b)

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Originally posted by Michael Torrie:
    I really do not know what you are asking. If the pascal program did:

    WriteLn("Enter your name: ")
    ReadLn(age)

    then in PB, you could do:
    Print "Enter your name: "
    Input age

    or

    Input "Enter your name: ",age

    If you want a C-style, formatted print or input, then that's a lot more complicated, although PB seems to do fine with print and input.

    In your first post you already have examples of this. What are you looking for? Please give us more information.

    Hi,

    Can you please give your emailadres to me then can I writing an
    email for the problemdefinition about new statements for
    PowerBasic:
    Name statement : input to the keyboard Read and ReadLn
    Syntax : DECLARE SUB Read(BYVAL variabele of datatypes) I think
    Function: User input an digit or an string in the variabele
    DIM a AS STRING
    DIM digit1 AS BYTE|WORD|INTEGER|DWORD|QWORD...
    DIM digit2 AS SINGLE|DOUBLE| ==> floats

    Read(a) ===> user type this is testing
    Read(digit1) ====> user type 124 or 64000 or -4514 or...
    Read(digit2) ====> user type 45.4512 or 12.4512E15 or...
    Read statement :reading the variabele and control datatype en formatting
    Readln is with CR/LF

    Name statement : OUTPUT to the screen Write en WriteLn

    Syntax : DECLARE SUB Write[Ln]() I think
    Formattype is for formatting integers, strings, floats
    for integers : only the position parameter
    for floats: the position and the fraction parameter
    Of is that possible formatting like C ==> printf("testing getal %d",digit)????

    Function:

    DIM A AS INTEGER
    DIM B AS SINGLE

    A = 4578
    B = 45141.451781

    Write "this is an digit %d", a =======> 4578
    Write "This is an digit %f3.2", b =====> 451.45

    WriteLn is with CR/LF is the same function

    Can you please written this code in PB for me in Assembly or PB?
    Its for using in PBDOS en PBCC

    Thanks,
    stephane




    ------------------

    Leave a comment:


  • Michael Torrie
    replied
    I really do not know what you are asking. If the pascal program did:

    WriteLn("Enter your name: ")
    ReadLn(age)

    then in PB, you could do:
    Print "Enter your name: "
    Input age

    or

    Input "Enter your name: ",age

    If you want a C-style, formatted print or input, then that's a lot more complicated, although PB seems to do fine with print and input.

    In your first post you already have examples of this. What are you looking for? Please give us more information.

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Originally posted by Michael Torrie:
    All of the things you are asking for, technically don't need to be part of PB at all. Instead, you should write your own libraries to do these things in this way. If you ever work with C, you'll see that most things are simply calls to a library. Under the hood, PB does have its own runtime library that drives many functions like print and input. Pascal has that too. Thus the Pascal forms you present are really not faster at all, at least by definition. The conversions you call slow still have to take place. (Numbers have to be parsed from an input string.) The ability in pascal to output a number to a specific decimal place is probably done in a similar way to how PB does it.

    As for PowerBasic having too many conversion here and there, remember that the compiler can determine at compiletime the various types of the variables and call the appropriate version of a function. PB has been around a long time, and, if I recall correctly, still has a ton of assembly code in it and probably hand-optimized code. I think it with the exception of dynamic strings (slow by nature) it will out-perform any DOS compiler out there (IMHO).

    Hi,

    I'm agree but the IDE from de PBDOS is not so professional.
    I will see an IDE like Borland Pascal.

    Can you writing an routine Write(Ln) and Read(Ln) with input with the
    keyboard strings and other datatypes for mee, thanks

    Greetings,
    stephane

    Can you please some from PBVISION/WORKSHOP????




    ------------------

    Leave a comment:


  • Michael Torrie
    replied
    All of the things you are asking for, technically don't need to be part of PB at all. Instead, you should write your own libraries to do these things in this way. If you ever work with C, you'll see that most things are simply calls to a library. Under the hood, PB does have its own runtime library that drives many functions like print and input. Pascal has that too. Thus the Pascal forms you present are really not faster at all, at least by definition. The conversions you call slow still have to take place. (Numbers have to be parsed from an input string.) The ability in pascal to output a number to a specific decimal place is probably done in a similar way to how PB does it.

    As for PowerBasic having too many conversion here and there, remember that the compiler can determine at compiletime the various types of the variables and call the appropriate version of a function. PB has been around a long time, and, if I recall correctly, still has a ton of assembly code in it and probably hand-optimized code. I think it with the exception of dynamic strings (slow by nature) it will out-perform any DOS compiler out there (IMHO).

    ------------------




    [This message has been edited by Michael Torrie (edited September 16, 2000).]

    Leave a comment:


  • Lance Edmonds
    replied
    Stephane, please do NOT cross-post the same requests to multiple forums... we heard you the first time.

    Thank you.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • New statements in PBDOS/PBCC for reading direct integers, floats,.... en new commands

    Dear Tom and other programmers,

    Is that possible for een input function buildin for digits like Pascal Read en ReadLn.
    Is not interesting to converting from string tot single, double, integer, word, byte.

    I think so an example

    "=================================================================="
    " Application: Sinus-math "
    "=================================================================="

    "=================================================================="
    " Definition constant "
    %PI = 3.14159265359 "
    "=================================================================="

    "=================================================================="
    " Declaration variabels "
    "=================================================================="
    DIM XG AS SINGLE
    DIM XR AS SINGLE
    DIM SX AS SINGLE
    DIM SXR AS SINGLE

    "=================================================================="
    "Begin program PBDOS/PBCC "
    "=================================================================="

    INPUT "Enter an angle in graden", XG // Problems conversion to an string is needed ==> program slower

    '// Pascal very easy : Write('Enter an angle in graden');
    ReadLn(XG);
    '// Faster program ==> no conversion!!!!

    XR = XG * PI / 180
    SX = SIN(XR);
    SXR = ROUND(SX * 100) / 100

    '// Faster statement ==> no conversions
    '// WriteLn('De sinus daarvan is ', SXR : position : decimals);

    PRINT USING "De sinus daarvan is",.....


    // To much problems en to much conversions with the statements INPUT, PRINT, PRINT USING.
    // Is better that the statements works with strings (separate SPRINT, SINPUT) and digits all types (INPUT, PRINT)

    SINPUT "Geef een getal in", a$ // Only for strings

    INPUT "Geef een getal in", a? | a?? | a???, | a& | a&& | a! | a# | a## | [email protected] | [email protected]@ // Only digits inputting

    SPRINT "Geef een string weer", variabele : position : decimals
    position and decimals : format like C with %<datatype><position><frac>

    --> Fast compiling
    --> easy programming for the programmer
    --> No conversion from digits in string of strings to digits

    Can you please A.S.A.P this new statements buildin to PBDOS, PBCC new versions!!!!!

    Greetings,
    stephane


    ------------------
Working...
X