Announcement

Collapse
No announcement yet.

illegal function call

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

  • Don Schullian
    replied
    Mel,

    Here's a function and a 2 liner you can use. IIRC PB/DOS did things like this.
    DIM A(1 TO LEN(Text)) AS BYTE AS STRPTR(Text)
    ARRAY SORT A()

    Code:
    FUNCTION SortWord ( BYVAL Text AS STRING ) AS STRING
    
      DIM L AS LOCAL INTEGER
      L = LEN(Text)
    
      IF L > 1 THEN
        DIM A(L-1) AS BYTE AT STRPTR(Text)
        ARRAY SORT A()
      END IF
      
      FUNCTION = Text
    
    END FUNCTION
    ------------------
    C'ya
    Don
    [email protected]

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    DO UNTIL MID$(text$,L,1) => MID$(text$,L-1,1) OR L = 1
    Not tested, but....

    You need to check if L=1 BEFORE you use 'L-1' in the MID$ statement, otherwise you are taking MID$(text$, 0,....)

    So try this..
    Code:
    DO UNTIL L=1 OR MID$(text$,L,1) => MID$(text$,L-1,1)
    .. to force exit before the illegal MID$ statement is even attempted.


    MCM


    Leave a comment:


  • Mel Bishop
    started a topic illegal function call

    illegal function call

    in another post, http://www.powerbasic.com/support/pb...ad.php?t=20285
    i asked for a more efficient way to sort the letters in a word.
    jose's reply sparked a remembrence and i modified a short sort
    routine i developed in the days of the ti/99-4a.

    got it to work okay in cc but since cc doesn't have mtimer, i
    copied it over the pb/dos and did some minor restructure so i
    could see how fast it operates. here is the dos version:
    Code:
        $lib all off
        $error all on
        color 14,1
        cls
    
        text$ = "zyxwvutsrqponmlkjihgfedcba"
        locate 1,1 : print;text$;
    
        text$ = sortword$(text$)
        locate 2,1 : print;text$;
        end
    
    function sortword$(text$)
    
        for x = 2 to len(text$)
        l = x
    
    10  do until mid$(text$,l,1) => mid$(text$,l-1,1) or l = 1
    
        s1$ = mid$(text$,l-1,1)
        mid$(text$,l-1,1) = mid$(text$,l,1)
        mid$(text$,l,1) = s1$
        l = l - 1
    
        loop
        next x
        function = text$
    
        end function
    it compiles okay but trying to run it produces an "illegal function
    call" on line 10 and i can't figure out why. the exact same thing
    compiles and runs fine under cc but not dos. i am running xp/pro.

    any ideas? thanks.


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


    [this message has been edited by mel bishop (edited october 19, 2003).]
Working...
X