Announcement

Collapse
No announcement yet.

Strange Behavior

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

  • Spencer Shearer
    replied
    Thanks José for QAing my code. I could not see the forest through the trees after looking at the code so long.

    Spencer

    Leave a comment:


  • José Roca
    replied
    But doing a bad calculation...

    Change

    Code:
    FUNCTION = MID$(xmlBuffer, startPos& + LEN(startNode), endPos& - LEN(endNode) - startPos& + 1)
    to

    Code:
    FUNCTION = MID$(xmlBuffer, startPos& + LEN(startNode), endPos& - LEN(startNode) - startPos&)

    Leave a comment:


  • Spencer Shearer
    replied
    Although your suggestion is a good one, it does not explain what is going on here. This is simple code doing a simple task and using PB functions in a straight forward manner.

    Leave a comment:


  • Edwin Knoppert
    replied
    Stop using custom parsers!
    Use MSXML the object(s)

    Leave a comment:


  • Spencer Shearer
    started a topic Strange Behavior

    Strange Behavior

    I am using PB CC 4.0.4.0042. I have a sample below of a program that I am writing that demonstrates some behavior that I cannot explain. The following is the output when the program is run:

    $300,000
    <descrip seqnum='1' code='B40'>higher education</descrip>
    Applications not accepted.</accepts

    The first two line of output matches what I thought I would see. The third line does not. It should read:

    Applications not accepted.

    Any idea why this behavior is taking place?

    Code:
    #COMPILE EXE
    #DIM ALL
    
    FUNCTION getXMLElementText(BYREF xmlBuffer AS STRING, startNode AS STRING, endNode AS STRING) AS STRING
        LOCAL startPos&
        LOCAL endPos&
        LOCAL nodeAttribute AS STRING
        LOCAL tempString    AS STRING
    
        startPos& = INSTR(xmlBuffer, startNode)
        IF startPos& THEN
            endPos& = INSTR(xmlBuffer, endNode)
            IF endPos& THEN
                FUNCTION = MID$(xmlBuffer, startPos& + LEN(startNode), endPos& - LEN(endNode) - startPos& + 1)
            END IF
        END IF
    END FUNCTION
                 
    
    FUNCTION PBMAIN () AS LONG
        
        STDOUT getXMLElementText("<total-giving>$300,000</total-giving>", "<total-giving>", "</total-giving>")
        'Result is $300,000
        STDOUT getXMLElementText("<flds-of-interest><descrip seqnum='1' code='B40'>higher education</descrip></flds-of-interest>", "<flds-of-interest>", "</flds-of-interest>")
        'Result <descrip seqnum='1' code='B40'>higher education</descrip>
        STDOUT getXMLElementText("<accepts-appl code='N'>Applications not accepted.</accepts-appl>", "<accepts-appl code='N'>", "</accepts-appl>")
        'Result: Applications not accepted.</accepts
    
    END FUNCTION
Working...
X
😀
🥰
🤢
😎
😡
👍
👎